6.3 Saving a procedure

Because we do not wish to rewrite each time the same instructions to draw a square, a triangle... it’s better to save these instructions into a “procedure”. To define a procedure, open the editor. A procedure starts with the keyword to and finishes with the keyword end. To define a square procedure:

to square  
repeat 4[fd 100 rt 90]  
end

then we close the editor by clicking on the turtle button. It will save the editor contents. Now, when we write square in the command line, a square appears on screen!