next up previous contents index
Next: Primitive 'trace' Up: Procedures Previous: Procedures   Contents   Index

Optional variables

It's now possible to add optional arguments to XLogo's procedure. Look at the example below:
to poly :n [:l 10]
repeat :n [fd :l rt 360/:n]
end

# this command will draw a regular polygon with 
# 20 sides of 10  
poly 20

During the interpretation, the variable :l has been replaced by its default value, I mean 10. If I we want to modify this value, we have to call the procedure poly between parenthesis to notice to the interpreter that we're going to use optional arguments.

# This command will draw a regular polygon with 20 
# sides. Every side is 5 long. 
 (poly 20 5)
# This is a square with each side equal to 100
(poly 4 100)


Loïc 2008-06-08