Objects
Object commands create and destroy objects like turtles, or the objects defined in additional extensions to Terrapin Logo Pro. The built-in TELL list is often used to talk to a specific set of objects. For a description of commands around TELL, see the turtle commands.
Once created, objects live forever unless you erase them with the ERASE command.
.WHO
Reports a list of widgets listening to commands.
Syntax
.WHO
Description
.WHO reports the list of currently active turtles, or other widgets, as set by the TELL command. The output is always a list regardless of the number of widgets that a previous TELL command has set. This is different from the WHO command.
See also ASK, SETTURTLES, TURTLES, and TELL.
Examples
TELL 0 WHO Result: 0 .WHO Result: [0]
ALLTURTLES
A list of all turtles.
Syntax
ALLTURTLES
Description
ALLTURTLES outputs a list of the names of every turtle that currently defined in Logo. ALLTURTLES is equivalent to the command EVERY “TURTLE.
Examples
ALLTURTLES Result: [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]
ASK
Makes widgets execute a list of commands.
Syntax
ASK word runlist
ASK list runlist
Description
ASK causes the turtle(s) or other widgets named in its first argument to execute the commands in its second argument. ASK makes it possible to send commands to a turtle that is not currently active without making it one of the active turtles.
The first argument to ask can be either a single widget name or a list of widget names (like turtle numbers). The input may also be any other Logo widget, like a robot, or a bitmap, or a list of these widgets.
Logo sends the commands in the runlist to each widget in the list; if one of these widgets does not know the command, the execution proceeds silently. If any command outputs a value, the execution stops, and the value becomes the output of ASK. During the execution of ASK, the TELL list is set to the list that was handed to ASK as its first input; EACH, on the other hand, sets the TELL list to each of its inputs before executing the runlist.
Examples
TELL 0 ASK 1 [ST] ASK 1 [FD 100] WAIT 1000 ASK 1 [HT]
CHECKTYPE
Checks an value for a type.
Syntax
CHECKTYPE value type
Description
CHECKTYPE checks a Logo name for being an element of a certain type. Since a Logo name may be a turtle, or any other type, its properties vary from type to type. If the widget given as its first input does not match the type given as the second input of CHECKTYPE, Logo throws a runtime error. A Logo name may have more than one type. The value 0 can, for example, be a number, or a turtle. CHECKTYPE can be used to check a value for being a procedure, a number, or simply anything that Logo knows.
Examples
CHECKTYPE 0 “TURTLE CHECKTYPE “UNKNOWN “TURTLE
DECLARE
Also: DCL
Creates a widget.
Syntax
DECLARE kind name
Description
The DECLARE command allows you to create new Logo widgets, giving a new name a certain type. Logo uses this command internally to create widgets of all kinds, like robots and turtles. When a new Logo name is declared, Logo creates the widget according to its type. Note that widget names must be unique, so creating a TURTLE named STAN and an ARRAY named STAN will not work.
Widgets live forever until they are erased with the ERASE or DRAW commands.
Examples
DECLARE “BITMAP “JOHN ; a new bitmap with empty contents appears
EACH
Applies a runlist to every widget in the TELL list.
Syntax
EACH runlist
Description
EACH causes each of the currently active widgets on the TELL list to execute the commands contained in its input sequentially. Before executing the runlist, EACH sets the TELL list to each of the widgets on the original TELL list. This allows each of several turtles to be given a variable input or to be addressed by WHO.
See also ASK, SETTURTLES, TURTLES, and WHO.
Examples
TELLODD HOME EACH [PD SETH 30 * WHO FD 100]
EVERY
Outputs a list of widgets.
Syntax
EVERY name
Description
The EVERY command outputs a list of those widgets whose type is given as input.
Examples
EVERY “TURTLE Result: [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]
IS.A
Checks an widget for being of a specific type.
Syntax
IS.A widget type
Description
IS.A checks a Logo name for being an widget of a certain type. Since a Logo name may be a turtle, or any of the other widget types, its properties vary from type to type. If the widget given as the first input of IS.A matches the type given as the second input of IS.A, IS.A returns TRUE; otherwise IS.A returns FALSE. IS.A is handy for checking whether a Logo name has a certain built-in property. A Logo name may have more than one type. The value 0 can, for example, be a number, or a turtle. Logo knows several types, and the list keeps growing. Buttons, sliders, and other controls have their own type, but all controls are also CONTROLs. In addition, controls, turtles and bitmaps are also WIDGETs.
Examples
IS.A 0 “TURTLE Result: TRUE IS.A 0 “WINDOW Result: FALSE
NEW
Creates a new Logo widget.
Syntax
NEW kind
Description
The NEW command allows you to create new Logo widgets of a certain type. The output of this command is the name of the widget, which may be assigned to a Logo variable for later use. The NEW command is an abbreviation for (DECLARE :kind).
Examples
NEW “BITMAP Result: BITMAP.1
TELL
Defines a list of turtles (or other widgets) listening to commands.
Syntax
TELL number
TELL name
TELL list
Description
TELL activates the turtles (or other widgets) that respond to turtle commands. Widgets may be turtles, or other moveable widgets like buttons or bitmaps. A single number or name as an argument to TELL activates that single widget. A list of numbers or names activates all the widgets named in the list. Use TELLALL 0 (TURTLES - 1) to activate all available turtles. TELLEVEN and TELLODD also activate a range of turtles.
Before turtles may be activated, they must be defined by the SETTURTLES command. The default number of turtles available when Logo starts is 16. After startup or after execution of a SETTURTLES command, turtle 0 becomes the active turtle.
See also ASK, EACH, TURTLES, and WHO.
Examples
CTURTLES 16 TELL [0 1 2 3] FD 50
TELLALL
Tells a range of turtle numbers.
Syntax
TELLALL first last
Description
TELLALL activates a range of turtles to respond to turtle commands. TELLALL takes two numbers as arguments. The first number is the number of the first turtle in the range to be activated. The second number is the last turtle in the range to be activated. Use TELL to activate a single turtle or a list of turtles. Additional commands that activate a range of turtles are TELLEVEN and TELLODD. EVERY “TURTLE reports a list of all available turtles.
Examples
CTURTLES 16 TELLALL 0 3 FD 50
TELLEVEN
Tells all turtles with even numbers.
Syntax
TELLEVEN
Description
TELLEVEN activates all the even numbered available turtles. Before turtles may be activated, they must be defined by the SETTURTLES command. The default number of turtles available when Logo starts is 16. See also TELLODD, TELLALL, and WHO.
Examples
TELLEVEN WHO Result: [0 2 4 6 8 10 12 14]
TELLODD
Tells all turtles with odd numbers.
Syntax
TELLODD
Description
TELLODD activates all the odd numbered available turtles. Before turtles may be activated, they must be defined by the SETTURTLES command. The default number of turtles available when Logo starts is 16. See also TELLEVEN, TELLALL, and WHO.
Examples
TELLODD WHO Result: [1 3 5 7 9 11 13 15]
TYPEOF
Reports the type of a name.
Syntax
TYPEOF widget
Description
The TYPEOF command returns the type of the Logo name supplied as input. Logo knows several types, and the list keeps growing. Buttons, sliders, and other controls have their own type, but all controls are also CONTROLs. In addition, controls, turtles, and bitmaps are also WIDGETs.
Examples
TYPEOF 1.234 Result: NUMBER TYPEOF “HELLO Result: WORD ; Note that widget names take precedence! TYPEOF 0 Result: TURTLE
WHO
Reports a list of turtles (or other widgets) listening to commands.
Syntax
WHO
Description
WHO reports the list of currently active turtles, or other widgets, as set by the TELL command. (Widgets may be turtles or other moveable widgets like robots.) The output is either a list if there is more than one turtle listening, or a word, if only one turtle is listening. If you always need a list of widgets, regardless of how many are listening, use the .WHO command.
See also ASK, SETTURTLES, TURTLES, and TELL.
Examples
TELLALL 0 3 WHO Result: [0 1 2 3] TELL 0 WHO Result: 0