next up previous contents index
Next: Optional variables Up: The workspace Previous: The workspace   Contents   Index

Procedures

Procedures are a kind of ``program''. When a procedure is called, the instructions in the body of the procedure are executed. A procedure is defined with the keyword to.

  to name_of_procedure :v1 :v2 :v3 .... [:v4 ....] [:v5 ....]
  Body of the procedure
  end

Eg:
  to square :s
  repeat 4[fd :s rt 90]
  end

The procedure is called square and takes a parameter called s. square 100 will therefore produce a square, the length of whose sides is 100. (See the examples of procedures at the end of this manual.)

Since version 0.7c, it is possible to insert comments in the code preceded by #.

to square :s 
#this procedure allows a square to be drawn whose side equals :s. 
repeat 4[fd :s rt 90] # handy, isn't it? 
end 



Subsections
next up previous contents index
Next: Optional variables Up: The workspace Previous: The workspace   Contents   Index
Loïc 2008-06-08