Logo Lesson 2 Logo Procedures TBE 540 40 Fall 2004 Farah Fisher Lesson Prerequisites Before beginning this lesson the student must be able to Start the Logo program appropriate version Create simple shapes using FD BK LT RT REPEAT Use pen control commands such as PU PD PE PPT PP Change pen color and background color using SETPC or SETBG or a menu Lesson Objectives After completing this lesson the student will be able to Explain the concept of Logo procedures Create a new Logo procedure Edit an existing Logo procedure Execute run a Logo procedure Save and load workspaces List all procedures in a workspace using POTS What is a Logo procedure When you used Logo in Lesson 1 each time you typed a command or set of commands the turtle moved immediately However the turtle did not remember how to make the shape To create the shape again you needed to type the commands again A procedure is a way to make the turtle remember a set of commands What is a Logo procedure Each procedure is given a name e g SQUARE or HOUSE or BIG RED THING The name may not include spaces Creating the procedure is like teaching the Logo turtle the meaning of a word For example we can teach the turtle that the word SQUARE means REPEAT 4 FD 50 RT 90 Afterwards every time we type the word SQAURE the turtle will know what to do What is a Logo procedure Procedures are kept in memory as part of a Logo workspace The workspace is a collection of all the Logo procedures currently in memory These workspaces can be save and loaded just like other documents More information about workspaces will be presented later How do you create a procedure Various versions of Logo may ask that you begin procedures in different ways This lesson will show two of the most common ways to start making a procedure Check the manual or HELP function of your version of Logo for more information Creating a Procedure using TO All Logo procedures actually have the word TO as part of the name e g TO SQUARE or TO HOUSE All versions of Logo allow this method for creating procedures To begin a procedure type the word TO and a name for the procedure For example you could type TO MY NAME or TO TRIANGLE Creating a Procedure using TO You will see a symbol like this The symbol means it is your turn to type something Type one or more Logo commands and press Return Enter Another will appear After you have finished all commands type END at the symbol NOTE You cannot immediately edit a previous line using this method You must edit later Creating a Procedure using EDIT All versions of Logo allow you to edit an existing procedure using the command EDIT Some versions of Logo also allow EDIT to be used to create new procedures check your HELP file or manual To begin a new procedure or edit an old one type the word EDIT a quote and the procedure name Example EDIT SQUARE Creating a Procedure using EDIT There are several things to notice when using the EDIT command e g EDIT HOUSE BOAT There is a space after the word EDIT There is no space between the quote and the name of the procedure There is no quote after the procedure name Many Logo commands follow this pattern Creating a Procedure using EDIT You will probably see the following two lines in the editing window when you begin a new procedure TO SQUARE or whatever you specified as the name END You will be typing the commands between these two lines so you may need to press Return Enter to open up space to type Creating a Procedure using EDIT Finishing and saving a procedure using EDIT will depend on the version of Logo you are using There may be a menu item such as Save and Exit There may be a specific command on the keyboard The simplest way is to attempt to close the editing window The computer should ask if you want to save the changes The Logo Workspace Earlier in this lesson a workspace was defined as a collection of procedures in memory Every time you create and save a procedure it becomes part of the current workspace NOTE Saving a procedure does not put it on a disk It exists only in memory until the entire workspace is saved The Logo Workspace The POTS command Print Out Titles shows you a list of all the procedures in memory In the list each procedure name will have the word TO in front of it For example the is the prompt in most Logo versions no need to type it POTS TO SQUARE TO TRIANGLE TO HOUSE Saving a Logo Workspace To save a workspace on disk including all procedures in memory type SAVE filename The filename may be anything that is appropriate for your operating system In some versions of Logo an extension of LGO will be added to the end of the filename There may be a menu item for SAVE in some versions of Logo Loading a Logo Workspace To load a workspace that has previously been saved to disk including all procedures in memory type LOAD filename All procedures will come into memory If some procedures are in memory before the LOAD the new ones will simply be added to the POTS list There may be a menu item for LOAD in some versions of Logo Summary of Steps to Create a Logo Procedure Decide what commands will be included in your Logo procedure and think of a name for it with no spaces In your Logo program do one of the following Type TO and the procedure name TO SQ Type EDIT and the procedure name EDIT SQ Enter the commands in the procedure Summary of Steps to Create a Logo Procedure When you have finished the procedure exit and save using one of these methods If you began with TO type END on the last line If you began with EDIT close the window and save or use the appropriate menu choice or keys Your procedure will become part of the POTS list Summary of Steps to Create a Logo Procedure Create other procedures as necessary Remember to SAVE the workspace on disk so that you can use it again e g SAVE FIRST Running a Logo Procedure After you have created a procedure you will want to see if it works Type the name of the procedure without TO to begin For example if the procedure is listed as TO THING type THING to start the procedure Use EDIT procedurename to correct mistakes Procedure Names as Logo Commands After you have created a Logo procedure you can use its name as a command in another procedure NOTE The procedure name you use must be in the current POTS For example if you have created a procedure called TO SQUARE you can include the command SQUARE in a procedure called TO HOUSE Procedure Names as Logo Commands Example TO …
View Full Document