Presentation is loading. Please wait.

Presentation is loading. Please wait.

Logo Lesson 2 Logo Procedures

Similar presentations


Presentation on theme: "Logo Lesson 2 Logo Procedures"— Presentation transcript:

1 Logo Lesson 2 Logo Procedures
TBE Fall 2004 Farah Fisher

2 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

3 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

4 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.

5 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.

6 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.

7 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.

8 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

9 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.

10 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

11 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.

12 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.

13 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.

14 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.

15 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

16 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.

17 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.

18 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.

19 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.

20 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)

21 “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.

22 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.

23 Procedure Names as Logo Commands
Example: TO TRIANGLE REPEAT 3 [FD 50 RT 120] END TO WINDMILL REPEAT 4 [TRIANGLE RT 90]

24 Self Check for Lesson 2 A Logo procedure is…
A shape that you make with the turtle. A set of commands stored together under one name. A logo command (e.g. PROCEDURE 7)

25 Self Check for Lesson 2 A Logo procedure is…
A shape that you make with the turtle. A set of commands stored together under one name. A logo command (e.g. PROCEDURE 7)

26 Self Check for Lesson 2 To begin entering a Logo procedure called GREEN, you should type… BEGIN “GREEN EDIT “GREEN TO GREEN

27 Self Check for Lesson 2 To begin entering a Logo procedure called GREEN… Type BEGIN “GREEN EDIT “GREEN {Most version of Logo TO GREEN allow either of these.}

28 Self Check for Lesson 2 After creating the procedure called GREEN, to start it you would type… BEGIN “GREEN “GREEN GREEN RUN “GREEN

29 Self Check for Lesson 2 After creating the procedure called GREEN, to start it you would type… BEGIN “GREEN “GREEN GREEN Just type the procedure name RUN “GREEN

30 Self Check for Lesson 2 When you type POTS, you see…
A list of all procedures in memory. A picture of a pot. A list of all files on the disk. A list of all possible Logo commands

31 Self Check for Lesson 2 When you type POTS, you see…
A list of all procedures in memory. A picture of a pot. A list of all files on the disk. A list of all possible Logo commands

32 Self Check for Lesson 2 When you type SAVE “BASICS
The procedure called BASICS is saved on the disk. The picture called BASICS is saved on the disk. All the procedures in POTS are saved on the disk in one file called BASICS. Each of the procedures in POTS is saved on the disk under its own name.

33 Self Check for Lesson 2 When you type SAVE “BASICS
The procedure called BASICS is saved on the disk. The picture called BASICS is saved on the disk. All the procedures in POTS are saved on the disk in one file called BASICS. Each of the procedures in POTS is saved on the disk under its own name.

34 Self Check for Lesson 2 To get the procedures in the BASICS file back into POTS (the workspace), type UNSAVE “BASICS GET “BASICS LOAD “BASICS You cannot retrieve the files once they have been saved.

35 Self Check for Lesson 2 To get the procedures in the BASICS file back into POTS (the workspace), type UNSAVE “BASICS GET “BASICS LOAD “BASICS You cannot retrieve the files once they have been saved.

36 Try some Logo procedures
See the hands-on exercise at Possible answers are found at


Download ppt "Logo Lesson 2 Logo Procedures"

Similar presentations


Ads by Google