5.2 Procedures

In addition to these primitives, you can define your own commands. These are called procedures. Procedures are introduced by the word to and conclude with the word end. They can be created using the internal XLOGO procedure editor. Here is a short example:

 
to square  
repeat 4[forward 100 right 90]  
end  

These procedures can take advantage of arguments as well. To do that, variables are used. A variable is a word to which a value can be assigned. Here is a very simple example:

to total :a :b  
print sum :a :b  
end  
 
total 2 3  
5