Logo Lesson 4 TBE 540 40 Fall 2004 Farah Fisher Prerequisites Create basic and complex shapes using Logo procedures Create Logo procedures that use variables Create a complex shape using simple shapes with variables Access the world wide web using a browser Use a search engine to find information Download text and graphics from the web Objectives Given a Logo procedure that does not work correct all errors Create a Logo procedure that accepts input from the keyboard while running Locate articles and presentations about Logo Locate websites about Logo Debugging When a program e g a Logo procedure is written it does not often work correctly the first time Correcting errors in a program is called debugging The term comes from the 1940s when moths were interfering with the operation of mainframe computers that used telephone relays as switches Debugging In order to debug a program it is necessary to know the programming language being used and what the program is supposed to do First look for typos misspelled commands missing incorrect spacing etc Debugging Then look carefully at each line of the program and run it in your head or try the results on paper step by step Make no assumptions do exactly what the program commands say to do If the program is complex try making one change at a time then running the program again Debugging Look at the Logo command below It is supposed to make a square REPEAT 4 FD50 RT 50 In looking for typos you will notice that the space in FD50 is missing The other error requires knowledge of Logo Stepping through the program shows that a turn of 50 degrees is not enough to make a square Debugging Try the debugging exercise at http www csudh edu fisher tbe540 LW4 htm Possible answers are available Keyboard Input In Lesson 3 you learned about variables and how to use MAKE and RANDOM to give variables a value It is sometimes useful for the person who is running the procedure to put numbers into variables by typing them while the procedure is running Keyboard Input Two Logo commands can be used for this purpose READLIST READCHARACTER or RC or READCH or READCHAR Both of these commands bring in information from the keyboard while a procedure is running Keyboard Input READLIST can bring in any amount of information everything the user types until Return Enter is pressed READCHARACTER or RC or READCH or READCHAR brings in just one character one keystroke Keyboard Input READLIST and READCHARACTER are used with MAKE to fill up a variable Examples MAKE NAME READLIST Everything typed until a Return Enter is put into NAME MAKE X FIRST READLIST Only information up to the first space is put into X prevents extraneous information MAKE Z READCHARACTER The first key pressed no Return is put into Z NOTE This is useful for Press any key to continue Keyboard Input Example The procedure below asks for the user to enter the size for a square and then draws it PR prints a message on the screen message is between the square brackets TO INSQUARE PR ENTER SIZE AND PRESS RETURN MAKE SIZE FIRST READLIST SQUARE SIZE END The procedure assumes that SQUARE with a variable is already in POTS any variable name is OK for SQUARE Keyboard Input Example The procedure below asks for the user to press any key to continue NOTE CS clears the screen TO MESSAGES PR HERE IS THE FIRST MESSAGE PR PRESS ANY KEY TO CONTINUE MAKE C READCHAR CS PR HERE IS THE SECOND MESSAGE END Keyboard Input See other samples at http www csudh edu fisher tbe540 L HO4 htm Self Check Lesson 4 The line below should make a triangle It has one or more errors Where are the errors REPET 4 FD100 RT 60 Self Check Lesson 4 The line below should make a triangle It has one or more errors Where are the errors REPET 6 FD100 RT 60 REPEAT should be 3 for a triangle needs a space FD 100 not enough degrees should be 120 for each of 3 turns Self Check Lesson 4 The following Logo commands were entered The error message was NOT ENOUGH INPUT What s wrong TO RECTANGLE L W REPEAT 2 FD L LT 90 FD W LT 90 END RECTANGLE 100 Self Check Lesson 4 The following Logo commands were entered The error message was NOT ENOUGH INPUT What s wrong TO RECTANGLE L W REPEAT 2 FD L LT 90 FD W LT 90 END RECTANGLE 100 Since there are two variables after RECTANGLE in the procedure definition two numbers should have been typed to start the procedure Self Check Lesson 4 Which of the Logo command below takes a single letter from the keyboard and puts it into a variable called KEYS MAKE KEYS READLIST READLIST KEYS READCHAR KEYS MAKE KEYS READCHAR Self Check Lesson 4 Which of the Logo command below takes a single letter from the keyboard and puts it into a variable called KEYS MAKE KEYS READLIST READLIST KEYS READCHAR KEYS MAKE KEYS READCHAR Self Check Lesson 4 You want to display the message ENTER YOUR NAME get the name and put it into a variable called WHOM Will the lines below work ENTER YOUR NAME MAKE WHOM READCHAR Self Check Lesson 4 You want to display the message ENTER YOUR NAME get the name and put it into a variable called WHOM Will the lines below work No see changes in blue PR ENTER YOUR NAME MAKE WHOM READLIST Locating Logo Websites You will need to find 5 websites about Logo for your bibliography Remember to record the complete address and write a brief description When you use a search engine such as http www google com use Logo programming as the search term This should remove websites about shirt logos etc from the list Locating Logo Articles Books You need to include 5 articles presentations or books about Logo in your bibliography references and descriptions Articles presentations and books about Logo can be found through the CSUDH Library at http library csudh edu A good source for articles and presentations about Logo is the online ERIC database References to books about Logo can be found in the online catalog Locating Logo Articles Books NOTE You may not be able to have full access to online library materials from home unless you register your ID card with the CSUDH Library For information click on Connect from Home Register as Library User on the Library home page or visit the library Locating Logo Articles Books When you access library csudh edu you will see Locating Logo Articles Books To see the online catalog choose this Locating Logo Articles Books Look for Logo in book titles Locating Logo Articles Books To access ERIC first choose this Locating Logo Articles Books Choose Subject List Locating Logo Articles Books Choose Education Locating Logo
View Full Document