
Logo Commands
The Workspace
Working with Data
Put data together
Access data
Test data or data contents
Create and manipulate arrays
Read, write, and print data
Working with Properties
Multimedia commands
Put data together
Access data
Test data or data contents
Create and manipulate arrays
Read, write, and print data
Working with Properties
Multimedia commands
Create and manipulate 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. See
also TELLALL
, TELLODD
, TELLEVEN
, EACH
, and WHO
.
Once created, objects live forever unless you erase them with the ERASE
command.
Reports a list of objects listening to commands.
.WHO
.WHO reports the list of currently active turtles, or other objects, as set by the
TELL
command. The output is always a list regardless of the number of objects
that a previous TELL
command has set. This is different to the WHO
command.
See also ASK
, SETTURTLES
, TURTLES
, and TELL
.
Makes objects execute a list of commands.
ASK word runlist ASK number runlist ASK list runlist
ASK causes the turtle(s) or other objects 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 object name or a list of object names (like turtle numbers). The input may also be any other Logo object, like a robot, or a bitmap, or a list of these objects.
Logo sends the commands in the runlist to each object in the list; if one of these objects 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.
You can also use ASK to ask a control to perform certain actions that are specific to the control (for that matter, we are talking about any callable properties at any object). For example, you can ASK a list box to APPEND
an item instead of having to use the CPROP
command. You cannot call callable properties inside a Logo procedure, though. Only ASK (and EACH
) know how to call callable properties. See also the page about Object properties for such commands.
Checks an value for a type.
CHECKTYPE value type
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 object 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.
Creates an object.
DECLARE kind name
The DECLARE command allows you to create new Logo names, giving a new name a certain type. Logo uses this command internally to create objects of all kinds, like robots and turtles. When a new Logo name is declared, Logo creates the object according to its type. Note that object names must be unique, so creating a TURTLE named STAN and an ARRAY named STAN will not work.
Objects live forever until they are erased with the ERASE
command.
Applies a runlist to every object in the TELL list.
EACH runlist
EACH causes each of the currently active objects 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 objects on the original TELL
list. This allows each of several turtles to be
given a variable input or to be addressed by WHO
.
You can also use EACH to ask a control to perform certain actions that are specific to the control (for that matter, we are talking about any callable properties at any object). For example, you can use EACH to ask a list box to APPEND
an item instead of having to use the CPROP
command. You cannot call callable properties inside a Logo procedure, though. Only EACH (and ASK
) know how to call callable properties. See also the page about Object properties for such commands.
See also ASK
, SETTURTLES
, TURTLES
, and WHO
.
Outputs a list of objects.
EVERY name
The EVERY command outputs a list of those objects whose type is given as input.
Checks an object for being of a specific type.
IS.A object type
IS.A checks a Logo name for being an object of a certain type. Since a Logo name may be a a turtle, or any of the other object types, its properties vary from type to type. If the object 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.
Creates a new Logo object.
NEW kind
The NEW command allows you to create new Logo objects of a certain type.
The output of this command is the name of the object, which may be assigned
to a Logo variable for later use.
The NEW command is an abbreviation for (DECLARE
:kind).
Defines a list of objects listening to commands.
TELL number TELL object TELL list
TELL activates the objects that respond to turtle commands. Objects may be turtles,
or other moveable objects like robots. A single number or names as an argument to
TELL activates that single turtle or object. A list of numbers or names activates all the objects
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.
Tells a range of turtle numbers.
TELLALL first last
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.
Tells all turtles with even numbers.
TELLEVEN
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
.
Tells all turtles with odd numbers.
TELLODD
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
.
Reports the type of a name.
TYPEOF name
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.
TYPEOF 1.234 Result: NUMBER TYPEOF "HELLO Result: WORD ; Note that object or widget names take precedence! TYPEOF 0 Result: TURTLE
Reports a list of objects listening to commands.
WHO
WHO reports the list of currently active turtles, or other objects, as set by the
TELL
command. The output is either a list if there is more than one object
listening, or a word, if only one object is listening. If you always need a list
of objects regardless of the number of objects listening, use the .WHO
command.
See also ASK
, SETTURTLES
, TURTLES
, and TELL
.
TELLALL 0 3 WHO Result: [0 1 2 3] TELL 0 WHO Result: 0