3.4 Storing all the steps

Sometimes, you want to draw something complicated with lots of steps. It is cumbersome to manually type each step. Also, you may want to recall those steps from time to time.

You can store multiple steps as a file in XLogo. Click the “Editor” button (lower right corner). This opens an editor box. In the editor box, type the follow sequence of steps as follows:

to drawtriangle  
forward 200  
right 120  
forward 200  
right 120  
forward 200  
end

Now you can use the “triangle tool” in the tool bar of the editor to accept the sequence. The extra lines “to drawtriangle ” and “end ” are used to indicate the sequence in between is collective called drawtriangle. As soon as you press the triangle button, you can now use the newly defined commnad drawtriangle to draw a triangle. Everytime you enter the command drawtriangle on the command bar, it is as if you manually enter all the commands.

It is a shame to lose our precious steps to draw a triangle. Use File | Save (which means first click the File menu, then select Save) to save the code to a file (with an extension of .lgo). This way, you can reload the same file later on and continue to add to it.