Learning Objectives
Video LessonsReference
Testing for UnderstandingRelated LinksLogo How-TosLogo in your browserLogo SoftwareLogo OrganizationsLogo ForumsThe work on this shelf is powered by you andMicroWorlds Web Player is officially supported under Internet Explorer or Netscape 4 or higher |
ProceduresWhat are procedures?We can talk about procedures (commands and reporters) in a couple of ways:
Some MicroWorlds procedures are written by programmers at LCSI (Logo Computer Systems, Inc.). Programmers like you can add new procedures by writing them in the public Procedures tab or the private Procedures tab in a turtles backpack. The procedures written by LCSI are already known by Foo when you get your copy of MicroWorlds. These procedures are called primitives. You can imagine an invisible Procedures tab somewhere behind the screen where all of the definitions for all of the primitives are written. Not everyone explains primitive procedures in this way. To understand why a correct definition is important, read this quote from Brian Harvey: Some writers and teachers reserve the word "procedure" to refer only to ones you write yourself, such as hello. They use the word "primitive" as a noun, to mean things like print and butfirst. They say things like "Logo instructions are made up of procedures and primitives." This is a big mistake. The procedures you write are just like the procedures Logo happens to know about in the first place. It's just that somebody else wrote the primitive procedures. But you use your own procedures in exactly the same way that you use primitive procedures: you type the name of the procedure and Logo evaluates that name by invoking the procedure. It's okay to say "Last is a primitive" as an abbreviation for "Last is a primitive procedure," as long as you know what you're talking about. Brian Harvey, Computer Science Logo Style, Volume 1, page 32 Where can you use procedures that you write?A procedure that you write works just the same way as a primitive. You can write a procedure that needs zero or more inputs. You can write a procedure that is a command or a reporter. Once your procedure is defined, you can use it anywhere you would use a primitive:
How do you write a procedure?(This section is taken from MicroWorlds EX Help > Programming > Programming Environment > About Procedures --TJ) A procedure has three parts: to square ; The title line "to" and the name of the procedure. All procedures must start with to and the name of the procedure. You choose the name, but always make sure that it doesn't contain any spaces. The name must be unique in the Procedures Tab in which the procedure is defined and it cannot be a name that exists in the MicroWorlds EX built-in vocabulary (primitives, object name, page name, etc.). Procedures must also end with the keyword end on its own line.
What does Foo do when he sees the name of my procedure in an instruction? Let's consider the procedure square from the example above. To follow along, you can write the square procedure in the Procedures tab of your project. The square procedure is a command that doesn't need any inputs. We'll talk later about how to write reporters and how to write procedures (commands or reporters) that need inputs. Once the square a command has been defined, you can write it at the beginning of a line of instructions. To see the trail that the turtle travels, you can use pd to put the turtle's pen down. Try running these instructions in the Command Center: pd square What happened? First, Foo reads pd. He does this by collecting one character at a time until he sees a space. Since pd is a primitive (a procedure written by the folks at LCSI), Foo follows the directions in the hidden (LCSI) procedures tab to collect inputs (in this case, there aren't any) and do what he has been asked (put down the turtle's pen). Next, Foo reads square. Since square is a procedure written by you, Foo follows the directions in Procedures tab you can open in the tabs section. The directions don't say anything about inputs, so Foo invokes the square procedure write away. He starts with the first line of instructions (fd 50 rt 90) and continues running instructions until he get to the end. So, if you use the definition of square that is written above, then pd square does the same work as: pd About the Center for Talent DevelopmentCenter for Talent Development (CTD), housed at Northwestern University's School of Education and Social Policy, is an accredited learning center and research facility that identifies, educates and supports gifted students and their families and serves as a leader in gifted education. Learn more about the Center for Talent Development. |
Leone Learning Systems, Inc. (LLS) is a North Shore company that provides online courses for kids anywhere and local teaching and tutoring services for students in Chicago and the Northern Suburbs of Chicagoland. LLS also provides a free geometry software package for children age 6 and up, and free resources for teachers and parents. This site includes information about classes taught, availability for tutoring, learning activities for kids, lesson plans, and ongoing software and curriculum research and development efforts. |
|