Reference

Video Lessons

Learning Objectives

Instruction Lists

Review of Words and Lists

Before we get started talking about instruction lists, let's review a little about words and lists.

We know that words are a group of characters that usually start with a quotation mark, like:

"ball "yx%q "Dolores

Numbers are a special kind of word that don't need quotation marks:

8 34 0.1

Words are used as input by commands and reporters:

fd 50 ; fd is a command that needs one input. fd likes numbers for its input.
settext1 "monkey ; settext1 likes any word as input when text box text1 is on the page.
show sum 5 7 ; sum is a reporter that needs two inputs. sum likes numbers for both inputs
.

There are reporters that output words. For example, xcor, ycor, heading, sum and random all output numbers.

The reporter word combines its two inputs into one word:

show word "star "fish
starfish

There are also commands and reporters that like lists as input. For example:

setpos [-40 22]
setshape [cow1 cow2 cow3 cow4 cow5 cow6]
talkto [t1 t2]
everyone [clickon]

There are also reporters that report lists, but we will save them for another lesson.

What's important for now is this:

Words or lists can be inputs or outputs of a procedure
Some procedures like any word or list as inputs. Some only like particular kinds of words or lists.

Lists in the Command Center and Lists in Procedure Tabs

Lists are treated a little differently in the Command Center and Procedure Tabs.

In the Command Center, Foo decides a list is finished when:

Foo sees a closing bracket, like the ] in [-40 22] OR
The Return key has been pressed, which signals to Foo that the instruction is complete.
So, for example, either one of these instructions would cause Foo to tell all the turtles to run the instruction in OnClick in their Rules Tab:

everyone [clickon]
everyone [clickon

In the Procedures Tab, Foo has a different way of deciding if instructions are complete. Foo uses key words like to and end to mark the beginning and end of the group of instructions that make up the procedure (Foo can also mark the end of a procedure with the key words stop, output, or stopall, which we will talk about in another lesson).

So, in the Procedures Tab, a list can begin on one line and end on another:

to transformToCow
setshape [
    cow1
    cow2
    cow3
    cow4
    cow5
    cow6
]
end

This is convenient for programmers like you, because it means you can write procedures that are easier to read.

Writing Procedures with Instruction Lists

Inside procedures, you can also write instruction lists that start on one line and end on another:

to go
everyone [
    setpos homebase
    setshape 1
    clickon
]
end

About the Center for Talent Development

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