You should be able to define the words below before you watch the videos. If you need help, click on the word to get its definition. For additional help, see Readings and Problems.
An instruction is a command together with the inputs it needs to do its work. For example, the line below contains two instructions:
fd 5 wait 1
A group of instructions that do a particular job is called a procedure. You can write your own procedures or use procedures called primitives that come with MicroWorlds.
Commands are procedures that are used to change the state of projects, pages, turtles, buttons, sliders, text boxes, colors, hyperlinks, media objects, dialog boxes, choosers and the Command Center.
Commands don't report output to other proceduresExamples of commands: presentationmode, page1, setx, fd, setslider1, set. The following procedures are not commands: xcor, sum, word, get.
A procedure that reports output to other procedures is called a reporter. The OP command is used to report output from procedures that you write yourself.
Examples of reporters: color, quotient, first, text1, get. The following procedures are not reporters: freezebg, page1, setc, fd, settext1, set.
Input is the information a procedure needs before it can be invoked. For example, in the following instruction
50 is the input to the fd command
Output is the information reported by a reporter. For example, in the instruction below
fd product 5 10
the output of the product reporter is 50.
A word is a collection of characters. The simplest way to get Foo to evaluate something as a word is to put quotation marks in front of it. Foo also recognizes numbers as words. Here are some words:
"hello 25 "|a word with spaces| "@.#%
Notice that an opening and closing bar (|) is used to make a word that contains spaces. Reporters may report words, but they may also report lists. Commands never report words or anything else.
A list is a collection of words. Brackets are used to show the beginning and end of a word. Here is a list:
[How are you?]
A list can be a member of a list.
[[chocolate fudge] vanilla [cherry garcia]]
The list above has three members. The first and third members are lists, and the second member is a word.
An instruction is evaluated when Foo reads it and decides whether to invoke a procedure, look for more input, or send back an error message. For example, suppose your project page has a text box called text1 and text1 has a 7 in it. You send the following message to Foo:
settext1 sum text1 1
Foo first evaluates
and next evaluates
sum 7 1
A procedure is invoked when it is made to do it work. Procedures are invoked in a particular order. For example, suppose you sent the following message to Foo:
show butfirst [show rest of words]
The first thing Foo sees is show, but he can't invoke show until he gets input for it, so the first procedure to be invoked is butfirst:
butfirst [show rest of words]
now Foo can invoke show:
show [rest of words]
How Foo Evaluates an Instruction
These videos use MDiagrammer (short for MicroWorlds Diagrammer) to create diagrams of messages to Foo (also called instructions). You need MicroWorlds EX to run MDiagrammer.
A setter and a word or list
A setter and a getter that outputs a word or list (Part 1)
A setter and a getter that outputs a word or list (Part 2)
A command and a math operator
A command and more than one math operator (Part 1)
A command and more than one math operator (Part 2)