User Tools

Site Tools


logo:quickref

Quick Reference

Logo commands, or primitives, and system names, or variables, are the basic building blocks of Logo programs and control of the Logo environment. Use Logo primitives to move the turtle, control the appearance of your computer screen, and to write procedures for your Logo projects. This chapter provides a brief definition of each Logo primitive and variable as a guide for Logo programming.

Logo Language Overview

Logo is a language that is easy to understand and quick to learn. For people used to computer programming, Logo presents features that are not common to modern programming languages like C++ or JavaScript. This chapter provides a brief overview over the Logo programming language for programmers.

The information does not replace a thorough tutorial. It does not even Please see our own Getting Started tutorial for more details. Brian Harvey's excellent three-volume book set “Computer Science Logo Style” is available as a free download on his web site at https://www.cs.berkeley.edu/~bh. This is highly recommended reading if you would like to become more familiar with Logo.

Data Types

Logo is an untyped language; variables and procedure parameters may contain any data type. Logo numbers are in 64-bit floating point format with up to 15 digits of decimal precision. Strings are 8-bit encoded; Unicode is not supported. Booleans are represented with the constants TRUE and FALSE. Logo converts these data types to the required types on the fly, just like JavaScript does.

The main data type is the list. Several commands are available for list access and manipulation. Arrays are separate objects with their own commands.

Property lists are also an important part of the language. Commands like GPROP or PPROP read and set properties. Property lists can also be converted into lists and back.

Turtles, bitmaps, arrays, and controls are property lists. You can, for example, read or set a turtle's position with property list commands. Some properties are callable; these properties correspond to C++ methods. Use commands like ASK or CPROP to execute these properties.

Constants

Numbers: Numbers are floating-point. Use the prefix #B, #O, #D and #H to enter binary, octal, decimal, and hex values like, for example, #HFA or #B1101.

Strings: A single leading double quote defines a string constant like “HELLO. These constants are converted to upper case unless the :CASE variable is set to FALSE. Strings enclosed in vertical bars are not converted; such a string constant needs to be quoted like “|Hello|. You can use backquotes to combine vertical bars and the double quote as in `Hello`.

Lists: Lists constants are enclosed in square brackets as in [HELLO |Joe|]. Note the second constant, which is a mixed-case string. No double quote is necessary.

Variables

The MAKE command stores a value into a variable as in MAKE “NAME “JACK. A single colon in front of a name loads the variable. Example:

MAKE "CENTER [0 0]
SETXY :CENTER

Variables are global except for procedure parameters and local variables, which need to be declared inside a procedure with the LOCAL command. Procedures have access to all variables in the calling procedure chain.

Parentheses

The () parentheses have a special meaning in Logo:

  • If used with a procedure call, Logo evaluates all arguments and feeds them into the procedure which is the list's first element. This makes it possible to call a procedure with a variable list of arguments. The PRINT command, for example, takes one argument, but if used with parentheses, PRINT accepts any number of arguments. (PRINT) prints a newline only, while (PRINT “A “B :CENTER) prints three values and a newline.
  • In arithmetic expressions, parentheses are used to group expressions as in any other programming language.

Procedures

The TO command defines a Logo procedure. The formal parameters (called “inputs” in Logo) are written as variables. the word END ends a procedure declaration. Procedures are lists; they can be declared dynamically with the DEFINE command, or extracted with the TEXT command. Self-modifying code is, therefore, possible.

A procedure input is written as :NAME. Optional inputs are written as two-element lists as in [:NAME value]. Note that Terrapin Logo does not evaluate optional inputs. Optional inputs must follow regular inputs. If the last input is single-element list like [:NAME], it acts as a catch-all input that collects all remaining inputs as a list. Finally, a procedure declaration may have a number as its last input that defines the number of default inputs. If no number is given, that number is the number of regular inputs.

Example:

TO FOO :NAME [:VALUE 5] [:REST]

Defines a procedure FOO with a regular input, a second, optional input that defaults to the value 5, and a last input that collects remaining values. If FOO is used without parentheses, it needs one input; it requires at least one input.

Examples:

  FOO 1
    :NAME = 1
    :VALUE = 5
    :REST = []
  
  (FOO 1 2 3 4)
    :NAME = 1
    :VALUE = 2
    :REST = [3 4]

Recursion is a basic Logo concept; use it whenever possible. Logo detects tail recursion properly.

The STOP command lets you exit a procedure, and the OUTPUT command lets you return a value.

Program Flow

Logo offers the usual set of program flow commands like IF, REPEAT, FOR, or WHILE. The FOREACH command iterates of a list or a word, and the TELL, ASK, and EACH commands iterate over turtles, bitmaps, and controls.

CATCH, THROW and TOPLEVEL are available for nonlocal program flow.

You can execute lists that you have assembled with the RUN ad EVAL commands.

Input and Output

Terrapin Logo supports files and folders. The OPEN command opens a file and outputs a channel number. You can assign this channel number to the global variables :STANDARD.INPUT and :STANDARD.OUTPUT to make all input/output commands work with this channel number, or you can supply the channel number to most I/O commands as an additional, optional input.

Organization

This list of Logo primitives and system names is organized by subject area. Commands that work in the same area, such as controlling the Logo turtle, are grouped together. Within each topic area commands are again organized by function, such as moving the turtle or changing the turtle's state. Within each subheading the commands are listed alphabetically. If you are interested in a particular function of Logo, you can go to the topic area and review the commands that are useful for achieving that purpose.

Format

The command listing is in two columns. The first column provides the syntax for the command with its name followed by any required inputs. Syntax for primitives that are often used with optional inputs is also listed. Note that when Logo primitives that are used with more or fewer than the default number of inputs, both the primitive and its inputs must be enclosed in parentheses as illustrated. The second column provides the abbreviation for the Logo command, if any. The full name and the abbreviation may be used interchangeably for any Logo primitives that have abbreviations. The following paragraph provides a brief definition of the function of the primitive or system name.

Terminology

The following words are used in the definitions of the Logo primitives and system names that are listed in this section (a dotted underline indicates the term is in this list):

: precedes a system name or variable to access it, and is equivalent to THING
precedes a special Logo word, such as a name
# precedes a command that changes the base of a number
indicates that any number of similar arguments may follow
bitmap graphics image that may be stored on disk or on the clipboard
character an alphanumeric character
channel an input or output stream identification number
color a color number, name, or 3-element RGB list
command one or more instructions to Logo
control a graphical Logo object used to display or get information, such as a checkbox, text edit field or static text.
current entity/turtle the first entity/turtle in the TELL list
descr a word containing file type descriptors
entity a Logo object that can be placed in a Graphics window, such as a turtle, bitmap or control
expression a statement whose output could be a word, a list, a number, or TRUE or FALSE
filename the name of a disk file
identifier a word, either a number or a name, that identifies an object
integer a whole number
list an ordered set of Logo objects surrounded by brackets
mode format for file reading and writing
name word naming a procedure, variable, or other Logo object
number an integer or decimal number
object a Logo object, such as a word, list, procedure, window or turtle
objecttype the name of a Logo object type
port an input/output port
primitive name of a Logo primitive (a built-in procedure)
procedure name of a Logo procedure
property name of a Logo property
shape a turtle shape name
TRUE Logo true object
FALSE Logo false object
[x y] a list specifying Cartesian x and y coordinates, or width/height

Commands

Built-in variables

Global built-in variables reflect the state of Logo. Some of these variables are read only, while changing others have effects on Logo programs. A few variables are actually property lists whose properties control Logo's behavior.

PLIST "LOGO.ENV
Contains a property list of global program and system settings.
GPROP "PREFS “propertyname
PPROP "PREFS “propertyname value
PLIST "PREFS
System-wide properties.
MAKE “BASE number
:BASE
Sets the numeric base used when printing numbers.
MAKE “CASE TRUE or false
:CASE
Makes Logo convert its input to upper case or not.
:CURRENT.GRAPHICS
Contains the current graphics window name.
:CURRENT.WINDOW
MAKE “CURRENT.WINDOW windowname
Contains the current window name.
:DATADIR
Reports the user's data directory.
:DESKTOPDIR
Reports the desktop directory.
:ERROR
Contains the type of the last runtime error.
:ERRORTEXT
Reports the text of the last caught runtime error or THROWn word.
:LOGODIR
Reports Logo's startup directory.
:PICTURE.FORMAT
Controls the format of saved pictures.
MAKE “PRECISION number
Sets the precision in which numbers are printed.
MAKE “STANDARD.INPUT channel
The number of the input stream.
MAKE “STANDARD.OUTPUT channel
The number of the output stream.
MAKE “TAB number
Sets the tab stop position.
MAKE “TRACE number
Controls the output of debugging information.
:USERNAME
Reports the login user ID.

Putting things together

This section contains all commands that put together Logo words or lists, or access elements of Logo words or lists.

FPUT word word
FPUT word list
FPUT list list
Prepends an element to its input.
ISEQ from to
(ISEQ from to increment)
Outputs a list of sequential integers.
LIST object1 object2
(LIST object1 object2 object3 …)
Concatenates its inputs to a list.
LPUT word word
LPUT word list
LPUT list list
Appends an element to its input.
PARSE word
Parses a string and outputs a list.
RSEQ from to count
Outputs a list of equally spaced rational numbers.
SENTENCE object1 object2
(SENTENCE object1 object2 object3 …)
(SE) Concatenates its inputs to a list, flattening lists.
SUBST what with wordorlist
Substitutes text in a word or a list.
WORD object1 object2
(WORD object1 object2 object3 …)
Concatenates its inputs to a word.

Accessors

Access data.

BUTFIRST word
BUTFIRST list
(BF) Reports all but the first element of its input.
BUTLAST word
BUTLAST list
(BL) Reports all but the last element of its input.
BUTMEMBER word.or.list1 word.or.list2
(BM) Removes an element from its input.
FIRST word
FIRST list
Reports the first element of its input.
FLATTEN list
Reports a flat version of its list input.
FROMMEMBER word/list word/list
(FM) Removes the first part of its input until a pattern is found.
ITEM number word
ITEM number list
Returns a specific element of its input.
LAST word
LAST list
Reports the last element of its input.
LOWERCASE word
Converts its argument to lower case.
MIXEDCASE word
Converts its argument to mixed case.
PICK object
Randomly picks an element.
UPPERCASE word
Converts its argument to upper case.

Queries

Test data or data contents.

COUNT word
COUNT list
Counts the number of items in its input.
DEFINED? name
(DEFINEDP) Checks whether a procedure is defined.
EMPTY? word
EMPTY? list
(EMPTYP) Checks whether a name is empty.
LIST? object
(LISTP) Checks for its input being a list.
MEMBER? word-or-list word-or-list
(MEMBER? word-or-list word-or-list TRUE)
(MEMBERP) Checks if an object is part of another object.
NAME? name
(NAMEP) Checks whether its input is assigned a value.
NUMBER? object
(NUMBERP) Checks its input for being a number.
PRIMITIVE? word
(PRIMITIVEP) Checks its input for being a built-in procedure or macro.
PROCEDURE? word
(PROCEDUREP) Checks its input for being a user-defined procedure.
WORD? object
(WORDP) Checks its input for being a word.

Arrays

Create and manipulate arrays.

An array is a creature from the early days of computing when everything was binary and the first counting number was zero so a three by three array (two dimensions) would be set up as

MAKE “A ARRAY [3 3]

which would sensibly numbered [1 1] through [3 3] but in fact the cells in the array are actually numbered as:

[0 0][0 1][0 2]
[1 0][1 1][1 2]
[2 0][2 1][2 2]

You would put “X” into the middle cell by ASET :A [1 1] “X (rather than the logical ASET :A [2 2] “X) which would result in…

[   ][   ][   ]
[   ][ X ][   ]
[   ][   ][   ]

Then someone would put “O” into the lower right cell by ASET :A [2 2] “O (rather than the equally logical ASET :A [3 3] “O) which would result in:

[   ][   ][   ]
[   ][ X ][   ]
[   ][   ][ O ]

…and so on. If an element has not been defined yet, it contains an empty list.

Access to elements of an array is much faster than access to elements of a list, because the location in the array can be pre-computed instead of having to walk through the list.

A bytearray is a special form of an array that contains byte values in the range between 0 and 255. These arrays are convenient to handle byte data, and they can be converted to a Logo word. If an element has not been defined yet, it contains the value 0.

AGET array number
AGET array list
Reports the value of an array element.
ARRAY number
ARRAY list
(ARRAY number list)
(ARRAY list list)
Creates an array.
ARRAY? object
(ARRAYP) Reports TRUE if the object is an array.
ARRAYDIMS array
Reports the structure of an array.
ASET array number value
ASET array list value
Sets the value of an array element.
BYTEARRAY number
BYTEARRAY list
(BYTEARRAY number word-or-list)
(BYTEARRAY list word-or-list)
Creates an array of byte values.
BYTEARRAY? object
(BYTEARRAYP) Reports TRUE if the object is a bytearray.
FILLARRAY array list or word
Sets the values of an array.
LISTARRAY array
Reports the values of an array as a list.
TEXTARRAY array
Sets the structure of an array.

Contents lists

Contents list commands manipulate several items at once using structured contents lists. Such a list is a three-element list, which are again lists. The first element is a list of all affected procedures, the seconds a list of all names, and the third a list of all properties. Structured contents lists are a new feature of Terrapin Logo 4; almost all commands in this section have changed from Terrapin Logo 3.

ALL
(CONTENTS, CO) Outputs a complete structured contents list.
BURIED
Outputs a structured contents list of all buried elements.
BURIED? name
(BURIEDP) Outputs TRUE if the element described by its input is buried.
BURIEDNAMES
Outputs a list of all buried names.
BURIEDPROCS
Outputs a list of all buried procedures.
BURIEDPROPS
Outputs a list of all buried property lists.
BURY procedureName
BURY [procedureName, procedureName, …]
BURY contents-list
(BURY procedureName procedureName …)
Makes names and procedures invisible.
BURYALL
Makes all names and procedures invisible.
BURYNAME name or list
Makes one or more names invisible.
BURYNAMES
Makes all names invisible.
BURYPROC name or list
Makes one or more procedures invisible.
BURYPROCS
Makes all procedures invisible.
BURYPROP name or list
Makes one or more property lists invisible.
BURYPROPS
Makes all property lists invisible.
EDALL
Edits the entire Logo workspace.
EDIT name
EDIT name1 name2 name3 . . .
EDIT [name1 name2 name3 . . .]
EDIT [structured contents list]
EDIT ALL
EDIT NAMES
EDIT PROCEDURES
EDIT PROPERTIES
(EDIT)
(ED) Edits parts or all of the Logo workspace.
EDL list
Edits a list.
EDN name or list
Edits one or more Logo names.
EDNS
Edits all Logo names.
EDP name or list
Edits one or more Logo procedures.
EDPL name or list
Edits one or more Logo property lists.
EDPLS
Edits all Logo properties.
EDPS
Edits all user-defined, unburied procedures.
ERALL
Edits the entire Logo workspace.
ERASE ALL
ERASE procname
ERASE [procname1 procname2 procname3 …]
ERASE NAMES
ERASE PROCEDURES
ERASE PROPERTIES
(ER) Erases Logo elements.
ERN name or list
Erase one or more Logo names.
ERNS
Erases all Logo names.
ERPL name or list
Erases one or more Logo property lists.
ERPLS
Erases all Logo properties.
ERPS
Erases all procedures.
NAMELIST name-or-list
Outputs a structured contents list with names.
NAMES
Outputs a structured contents list with all names.
PLISTS
(PROPERTIES) Outputs a structured contents list with all properties.
PLLIST name
PLLIST list
Outputs a structured contents list with properties.
POALL
Prints the entire Logo workspace.
PON name
Prints a Logo name.
PONS
Prints all Logo names.
POPL name or list
Prints one or more Logo property lists.
POPLS
Prints all Logo properties.
POPRS
Prints the title of all Logo primitives.
POPS
Prints all Logo procedures.
POT name or list
Prints the title line of one or more user-defined procedures.
POTS
Prints the title line of all user-defined procedures.
PRIMITIVES
Outputs a structured contents list with all primitives.
PRINTOUT procname
(PRINTOUT procname1 procname2 …)
PRINTOUT contents-list
PRINTOUT ALL
PRINTOUT NAMES
PRINTOUT PROCEDURES
PRINTOUT PROPERTIES
PRINTOUT PRIMITIVES
(PO) Prints procedures, names, or properties.
PROCEDURES
Outputs a list with all user procedures.
PROCLIST name
PROCLIST list
Outputs a structured contents list with procedures.
UNBURY procedureName
UNBURY [procedureName, procedureName, …]
UNBURY contents-list
(UNBURY procedureName procedureName …)
Makes names and procedures visible.
UNBURYALL
Makes all names and procedures visible.
UNBURYNAME name or list
Makes one or more names visible.
UNBURYNAMES
Makes all names visible.
UNBURYPROC name or list
Makes one or more procedures visible.
UNBURYPROCS
Makes all procedures visible.
UNBURYPROP name or list
Makes one or more property lists visible.
UNBURYPROPS
Makes all property lists visible.

Input and Output

Read and write data.

This section contains all commands that input or output data. The most used command is probably the PRINT command. Other commands work with files, or directories. All I/O goes through streams or channels. A channel has a number, which is used to reference the channel when doing I/O. The Listener stream has the channel number 0, and the Output output stream has the channel number 1. The OPEN command opens a file, and returns a channel number which can be used in subsequent I/O.

The :STANDARD.INPUT and :STANDARD.OUTPUT variables contain the channel number that Logo uses for I/O. Usually, this is the channel number 0, which is the Listener channel. You can use the OPEN command to obtain a channel number to a file, and assign that channel number to above variables to make all I/O commands work with that file. Also, many I/O commands accept a channel number as an additional, optional input, so you can use I/O commands for multiple channels if you wish.

ALERT message
(ALERT message button1)
(ALERT message button1 button2)
(ALERT message button1 button2 button3)
Displays an alert box.
CLEARINPUT
(CLEARINPUT channel)
Clears all input from a stream.
CLOSE channel
(CLOSE)
Closes a stream.
CREATE filename
Creates a file.
CREATE.DIR foldername
Creates a folder.
CURDIR
Reports the current working directory.
DELETE filename
Deletes one or more files from disk.
DIRECTORY
(DIRECTORY pattern)
(DIR) Lists the contents of current working directory.
EOF?
(EOF? channel)
(EOFP) Outputs TRUE if the current stream is at EOF.
FILE.INFO filename
Reports information about a file.
FILE? filename
(FILEP) Reports TRUE if a file or directory exists.
GETBYTE
(GETBYTE channel)
Reads one byte from the input stream.
KEY
Reports the code of the last key that the user typed.
OPEN filename
(OPEN filename mode)
OPEN []
(OPEN [] mode)
OPEN type-descriptors
(OPEN type-descriptors mode)
Opens a file and returns the channel number.
OPEN.PORT portnumber
Opens a serial port for I/O.
PEEKBYTE
(PEEKBYTE channel)
Returns the next character from the input stream without reading it.
PRINT object
(PRINT)
(PRINT object1 object 2 …)
(PR) Prints text with a line feed.
PRINTLINE integerlist
(PRINTLINE integerlist channel)
Prints a list of numbers as Unicode characters.
PRINTQUOTE object
(PRINTQUOTE object channel)
(PQ) Prints its input and a newline.
PUTBYTE number
(PUTBYTE number channel)
Writes a data byte or a Unicode character to the output stream.
PUTBYTES integerlist integer
(PUTBYTES integerlist integer channel)
Writes data bytes or characters to the output stream and reads a reply.
READ
Reads one Logo word.
READCHAR
(READCHAR channel)
(RC) Reads a character from the input stream.
READLINE
(READLINE channel)
Reads a line and outputs it as a list of numbers.
READLIST
(READLIST channel)
(RL) Reads a line and outputs it as a list.
READPROMPT text
(READPROMPT)
(RP) Opens a dialog box and reads a line.
READQUOTE
(READQUOTE channel)
(RQ) Reads a line.
READWORD
(READWORD channel)
Reads the first word of a line.
RENAME oldname newname
Renames a disk file.
SELECT.FILE filetypes
(SELECT.FILE filetypes title)
Displays a dialog to select a disk file.
SELECT.FOLDER
(SELECT.FOLDER prompt)
Displays a dialog to select a disk folder.
SETCURDIR directoryname
Changes the current working directory.
SHOW object
(SHOW)
(SHOW object1 object 2 …)
Prints text with a line feed.
SUBDIR
(SUBDIR pattern)
Lists the contents of current working directory.
TYPE object
(TYPE object1 object 2 …)
Prints text.
UNGETBYTE value
(UNGETBYTE value channel)
Pushes back one character to the input stream.

Property lists

Add, retrieve, call, or remove properties.

Properties are values that are stored as property lists. These lists are not traditional values that MAKE and THING can handle. Instead, there are separate commands to create, to read, to set, to invoke, or to remove properties.

Many objects have built-in variables that belong to the object itself instead of the toplevel workspace. A turtle, for example, has a variable POSITION that sets or reports the turtle's position. A turtle can be ASKed to MAKE a new position, like in ASK 0 [MAKE “POSITION [100 100]]. Alternatively, these object specific variables may be accessed as properties of that object. Instead of ASKing a turtle like above, you can set the turtle's POSITION property as in PPROP 0 “POSITION [100 100].

CPROP name propertyname
(CPROP name propertyname input-1 …)
Calls a property as a procedure.
GLIST property
Reports the property lists that contain a property with a given name.
GPROP name propertyname
Retrieves a property.
PLIST name
Reports the property list of a name.
PPROP name propertyname object
Stores a property.
PPROPS name list
Stores a list of properties.
REMPROP name propertyname
Removes a property.

Program Flow

Control the program flow.

This section describes various commands to control the program flow. The IF command implements branching, and various loop commands implement looping. CATCH and THROW implement a mechanism to pass control across procedure boundaries.

APPLY procedure list
Applies a parameter list to a procedure.
CATCH word instructions
CATCH TRUE instructions
CATCH “ERROR instructions
Catches runtime errors and THROWn data.
COPYDEF newname currentname
Copies a procedure definition.
DEFINE name instructionlist
Defines a procedure.
IF expression THEN instructions ELSE instructions
Starts the ELSE branch of an IF command.
END
Ends a procedure definition.
EVAL list
Runs a list and collects all outputs.
FOR variable-name start-value end-value [runlist]
(FOR variable-name start-value end-value [runlist] increment-value)
Runs a list for a defined number of times.
FOREACH word-or-list runlist
Runs a list for each element of its first input.
FOREVER runlist
Runs a list forever.
GO name
Jumps to a label inside a procedure.
IF expression [then-instructions]
IF expression [then-instructions] [else-instructions]
IF expression then-instructions
IF expression THEN instructions
IF expression THEN instructions ELSE instructions
Runs instructions based on a condition.
IFFALSE instruction-list
(IFF) Runs a list if TEST was false.
IFTRUE instruction-list
(IFT) Runs a list if TEST was true.
IGNORE object
Ignores the output of a procedure.
LABEL object
Marks a target for the GO command.
LOCAL name
(LOCAL name1 name2 …)
Declares local variables inside a procedure.
OUTPUT value
(OP) Exits a procedure and outputs a value.
REPCOUNT
Reports the value of the REPEAT counter.
REPEAT number list
Runs a runlist repeatedly.
REPTOTAL
Reports the total number of REPEATs.
RUN word-or-list
Runs a word or list.
STOP
Exits a procedure.
TEST expression
Test a condition; used with IFTRUE and IFFALSE.
TEXT procedurename
Outputs a procedure definition.
IF expression THEN instructions
IF expression THEN instructions ELSE instructions
Starts the THEN branch of an IF command.
THROW word
(THROW runtime-error-word text)
(THROW)
Throws a Logo word or a runtime error.
TO procname
TO procname :input …
TO procname … [:optional-input value] … argcount
TO procname … [:list-input] argcount
Defines a procedure.
TOPLEVEL
Returns to toplevel.
WAIT number
Waits for a number of milliseconds.
WHILE testlist runlist
Runs a list until a condition is false.

Background procedures

Working with background procedures.

Background procedures are procedures or runlists that run in the background at the same time as a normal program. There are commands available that launch a runlist or a procedure in the background.

HALT id
(HALT)
Stops one or all background procedures.
LAUNCH runlist
LAUNCH “procedurename
(LAUNCH “procedurename input1 …)
Launches a runlist or procedure for execution in the background.

Math

Arithmetic computations.

Logo understands quite a lot of math commands, from simple addition and subtraction up to functions like the cosecant, or the square root. Random numbers are part of the math functions as well.

number * number
* number number
(* number number number)
(PRODUCT) Calculates the product of its inputs.
number1 + number2
+ number1 number2
(+ number1 number2 number3 …)
(SUM) Reports the sum of its inputs.
number1 - number2
- number1 number2
(- number1 number2 number3 …)
(DIFFERENCE) Outputs the difference of two or more numbers.
number / number
/ number number
(/ number number number …)
(QUOTIENT) Reports the quotient of its inputs.
number < number
< number number
(.LT, LESS?, LESSP) Tests if its first input is less than its second input.
number <= number
<= number number
(.LE, LESSEQUAL?, LESSEQUALP) Tests if its first input is less than or equal to its second input.
object <> object
object <> object
<> object object
(!=, .NE, NOT.EQUAL?, NOT.EQUALP, NOTEQUAL?, NOTEQUALP) Tests its inputs for inequality.
object = object
= object object
(.EQ, EQUAL?, EQUALP) Tests its inputs for equality.
number > number
> number number
(GREATER?, GREATERP, .GT) Tests if its first input is greater than its second input.
number >= number
>= number number
(.GE, GREATEREQUAL?, GREATEREQUALP) Tests if its first input is greater than or equal to its second input.
ABS number
Reports the absolute value of a number.
AND input1 input2
(AND input1 input2 input3 …)
Logical AND.
ARCCOS number
(ACOS) Reports the arccosine.
ARCCOT number
(ACOT) Reports the arccotangent.
ARCCSC number
(ACSC) Reports the arccosecant.
ARCSEC number
(ASEC) Reports the arcsecant.
ARCSIN number
(ASIN) Reports the arcsine.
ARCTAN number
(ATAN) Reports the arctangent.
ARCTAN2 deltaX deltaY
(ATAN2) Reports the polar angle heading of the motion vector (position change) deltaX deltaY.
COS number
Reports the cosine.
COT number
Reports the cotangent.
CSC number
Reports the cosecant.
EXPN number
(EXP) Calculates the natural base e raised to a power.
INT number
Reports the integer part of a number.
LOG number
(LN) Outputs the natural logarithm of its input.
LOG10 number
Outputs the logarithm of its input.
LOGAND integer1 integer2
Combines its inputs with a boolean AND operation.
LOGNOT integer
Reports the bitwise logical complement of its input.
LOGOR integer1 integer2
Combines its inputs with a boolean OR operation.
LOGXOR integer1 integer2
Combines its inputs with a boolean XOR operation.
LSH integer integer
(ASHIFT) Shifts its input with sign extension.
MODULO dividend divisor
Outputs the remainder of two numbers.
NOT expression
Negates its input.
OR object1 object2
(OR object1 object2 object3 …)
Performs a logical OR on its input.
PI
Reports the number Pi.
RANDOM number
(RANDOM bottom top)
Outputs a random number.
dividend REMAINDER divisor
REMAINDER dividend divisor
(%) Outputs the remainder of two numbers.
RERANDOM number
(RERANDOM)
Seed the random number generator.
ROUND number
Rounds a number.
SEC number
Reports the secant.
SIN number
Reports the sine.
SQRT number
Reports the square root.
TAN number
Reports the tangent.
number ^ number
^ number number
(^ number number number …)
(POWER) Raises a number to the power of another number.

Debugging

Track program execution.

Debugging commands are essential to find programming errors. They help with inspecting programs and data, to pause a program, to find out why a program takes too much time, and much more. Logo can pause because of several reasons:

  • The PAUSE command has been executed
  • A runtime error has been hit
  • The PAUSE icon has been clicked, or the F4 key has been pressed

The debugging icons in the Toolbar have the following meaning:

Icon Key Command Explanation
F3 TOPLEVEL Halts a program and returns to toplevel.
F4 PAUSE Pauses a program and enters Pause mode.
BACKTRACE
(BT) Prints a backtrace.
CONTINUE
(CO) Ends a pause.
EXECTIME
Outputs the number of microseconds spent inside a procedure.
PAUSE
Pauses a procedure.

Creating Turtles

Create and assign turtles.

These commands handle the number of turtles, how they are created, and how to talk to them.

ALLTURTLES
A list of all turtles.
CTURTLES number
Arranges turtles in a circle.
LTURTLES number
Arranges turtles in a row.
SETTURTLENAME :turtle :name
(SETTNAME) Sets the name of a turtle.
SETTURTLES number
SETTURTLES number
(SETT) Creates a range of turtles.
SETTWINDOW windowname
Attaches a turtle to a Graphics window.
TURTLENAME
(TNAME) Gets the name of the first active turtle.
TURTLENAMES
(TNAMES) Outputs a list of all turtle names.
TURTLES
Reports the number of turtles.
TWINDOW
Outputs the name of the window of the first active turtle.

Turtle Drawing

Move turtles around, and make them draw.

Turtle movement commands control the speed and direction of the turtle movement. Drawing commands draw arcs, text, or fill areas.

BACK number
(BK) Moves a turtle backwards.
DISTANCE [x y]
Reports the distance between the turtle and a location.
DOT [xcoordinate ycoordinate]
(DOT)
Draws a dot.
DOT?
(DOT? [xcoordinate ycoordinate])
(DOTP) Tests whether a pixel with a color other than the background color is present.
DOTCOLOR [xcoordinate ycoordinate]
(DOTCOLOR)
Reports the color of a pixel.
FILL
(FILL color)
Fills an area.
FONT
Reports the current font of the first active turtle.
FONTS
Reports a list of all available fonts.
FORWARD number
(FD) Moves a turtle forward.
GETX
(XCOR) Reports the X coordinate of a turtle.
GETXY
(POS) Reports the coordinates of a turtle.
GETY
(YCOR) Reports the Y coordinate of a turtle.
HEADING
Reports the heading of a turtle.
HIDETURTLE
(HT) Hides a turtle.
HOME
Moves the turtle back to [0 0].
LEFT number
(LT) Turns a turtle left.
ORIGIN
Reports the origin of a turtle's coordinate system.
PANGLE
Reports the turtle's angle as a polar angle.
PDIST
Reports the distance from the turtle to its home.
PEN
Reports the pen mode.
PENDOWN
(PD) Puts the pen down.
PENDOWN?
(PENDOWNP) Checks whether the pen is down.
PENERASE
(PE) The pen draws with the background color.
PENREVERSE
(PX) The pen inverts all colors.
PENUP
(PU) The pen moves up.
PHEADING
Reports the turtle's polar heading.
PPOS
Reports the turtle's polar position.
PSETHEADING number
PSETHEADING number
(PSETH) Sets the polar heading of a turtle.
RIGHT number
(RT) Turns a turtle right.
SETFONT name size attributes
(SETFONT name size)
(SETFONT name)
(SETFONT)
(SETFONT [name size attributes])
(SETFONT [name size])
(SETFONT [name])
(SETFONT [])
Sets the turtle drawing font.
SETHEADING number
(SETH) Sets the heading of a turtle.
SETORIGIN xy
SETORIGIN [x y]
(SETORIGIN)
Sets the coordinate system origin of the active turtles.
SETP distance angle
Sets the turtle's polar position.
SETPEN [penstate pencolor]
Sets the pen characteristics.
SETSPEED number
Sets the speed in which turtle commands are executed.
SETSTEPSIZE pixels
Sets the step size of all active turtles and bitmaps.
SETTURTLESIZE number
(SETTSIZE, SETTS) Sets the size of a turtle.
SETVELOCITY number
Sets the independent speed of a turtle.
SETWIDTH number
(SETW) Sets the pen width.
SETX x-coordinate
Sets the X coordinate of a turtle.
SETXY [x-coordinate y-coordinate]
(SETPOS) Sets the coordinates of a turtle.
SETY y-coordinate
Sets the Y coordinate of a turtle.
SHOWN?
(SHOWNP) Reports whether a turtle is visible.
SHOWTURTLE
(ST) Makes a turtle visible.
SLOWTURTLE
Slows down the turtle to half speed.
SPEED
Reports the speed in which turtle commands are executed.
STAMPOVAL xradius yradius
(STAMPOVAL xradius yradius “TRUE)
Draws an oval.
STAMPRECT width height
(STAMPRECT width height “TRUE)
Draws a rectangle.
STEPSIZE
Outputs the step size of the first active turtle or bitmap.
TOWARDS [xcoordinate ycoordinate]
Reports the angle of a position compared to the turtle position.
TURTLESIZE
(TSIZE) Reports the size of a turtle.
TURTLETEXT whatToPrint
(TT) Prints its input on the Graphics window.
TURTLETEXTBASE
TURTLETEXTBASE
(TTBASE) Outputs the baseline offset of the first listening turtle's font.
TURTLETEXTSIZE “text
TURTLETEXTSIZE “text
(TTSIZE) Outputs the dimensions of a text drawn with the first listening turtle.
VELOCITY
Reports the independent movement speed of a turtle.
WIDTH
Reports the pen width.

Turtle Shapes and Bitmaps

Load and save turtle shapes and bitmaps.

The commands in this group load and save turtle shapes and bitmaps. A turtle shape is a bitmap that can be loaded from a disk file, or a rectangular area of the graphics window.

LOADSHAPE filename
LOADSHAPE filename.ext
LOADSHAPE type-descriptors
(LOADSHAPE)
Loads a turtle shape from disk and sets the shape of all active turtles.
LOADSNAP filename
LOADSNAP filename.ext
(LOADSNAP)
LOADSNAP type-descriptors
Loads a bitmap.
LOCKSHAPE
Prevents a bitmap from turning.
SAVESHAPE filename
SAVESHAPE filename.ext
(SAVESHAPE)
SAVESHAPE type-descriptors
Saves a turtle shape.
SAVESNAP turtle filename
SAVESNAP turtle filename.ext
(SAVESNAP turtle)
SAVESNAP turtle []
SAVESNAP turtle type-descriptors
Saves a turtle shape.
SETSHAPE name-of-shape
(SETSHAPE)
SETSHAPE filename
SETSHAPE filename.ext
SETSHAPE type-descriptors
Sets the shape of all active turtles.
SHAPE
Outputs the name of the first active turtle's shape.
SNAP width height
Moves parts of the graphics window into a bitmap.
SNAPSIZE turtle
Outputs the size of a bitmap.
STAMP
(STAMP bitmap)
(STAMP bitmap width height)
Draw a bitmap or turtle.
UNLOCKSHAPE
Lets a bitmap rotate according to the turtle's heading.

Colors

These commands assign colors to the background of the Graphics window, or the turtle pen. A color is one of three things: A number between 0 and 137 for the 138 Web colors, a color name (which is one of 138 standard Web color names, see COLORS), or a list of three values, one each for Red, Green, and Blue. These three values may vary from 0 to 255.

For a list of color names and their indexes or color values, see the Logo Colors page.

BACKGROUND
(BG) Reports the background color.
BGPATTERN
Reports the background pattern.
COLOR color-index
COLOR [red green blue]
COLOR “color-name
Reports the color for a name or value if possible.
COLORINDEX “color-name
COLORINDEX [red green blue]
(BASECOLOR) Coerces a color value to a basic Logo color number.
COLORNAME color-value
COLORNAME [red green blue]
Reports the name of a color if possible.
COLORS
Reports a list of available color names.
PATTERN
Reports the turtle's pattern.
PENCOLOR
(PC) Reports the pen color.
SETBG color-index
SETBG “color-name
SETBG [red green blue]
Sets the background color.
SETBGPATTERN number
SETBGPATTERN list
SETBGPATTERN bitmap-name
Sets the background pattern.
SETPATTERN number
SETPATTERN list
SETPATTERN turtle
Sets the turtle pattern.
SETPC color-value
SETPC “color-name
SETPC [red green blue]
Sets the pen color.

The Graphics window

The Graphics window is the drawing surface for the turtles.

BUTTON?
(BUTTON? button)
(BUTTONP) Reports the state of a mouse button.
CLEAN
Erases the graphics pane.
CLEARSCREEN
(CS) Erases the graphics pane and homes the turtle.
DRAW
Clears the current graphics window and resets all attached turtles.
EXTENT
Reports the extent of the current Graphics window.
FENCE
Fences all turtles inside the drawing borders.
GRID size
Sets the size of the graphics grid.
GRIDOFF
Hides the grid of the Graphics window.
GRIDON
(GRIDON [horizontal vertical])
Displays the grid of the Graphics window.
LOADPIC filename.ext
(LOADPIC filename.ext TRUE)
Loads a picture as background picture.
MOUSE
Reports the position of the mouse cursor.
MOUSESHAPE
Reports the shape of the mouse cursor.
SAVEPIC filename.ext
SAVEPIC type-decriptors
(SAVEPIC)
(SAVEPIC filename.ext “windowname)
Saves the contents of the Graphics window.
SETEXTENT extent
SETEXTENT [xExtent yExtent]
(SETEXTENT)
Set the extent of the current Graphics window.
SETMOUSESHAPE number
(SETMOUSESHAPE)
Sets the shape of the mouse cursor.
WINDOW
Removes the boundary for turtle movements.
WRAP
Lets the turtles wrap inside the window.

Pro-Bot Commands

Talk to the Pro-Bot.

Terrapin Logo 4 can upload Pro-Bot procedures, run them in Logo, and download them to the Pro-Bot. See the Programming the Pro-Bot page for details. This page also explains how to connect a Pro-Bot; you need to download and install a driver, and to buy a special USB cable before you can talk to a Pro-Bot.

PROBOT.LIGHTS TRUE or FALSE
Turns the Pro-Bot's headlights on or off.
PROBOT.READ
Uploads all Pro-Bot procedures into Logo's workspace.
PROBOT.SOUND 1 through 7
Plays Pro-Bot sounds.
PROBOT.WRITE
(PROBOT.WRITE units)
Downloads all Pro-Bot procedures to the Pro-Bot.
PROBOT?
(PROBOTP) Tests if a Pro-Bot is connected.

Blue-Bot Commands

Talk to Blue-Bot.

Terrapin Logo 4.1 can download Logo commands to a Blue-Bot robot. See the Programming Blue-Bot page for details. This page also explains how to connect a Blue-Bot.

Please note that you need Terrapin Logo version 4.1 or higher; older versions do not support the Blue-Bot commands.

BLUEBOT.CLEAR
Clears all commands stored in Blue-Bot's memory.
BLUEBOT.CLOSE
Closes the Blue-Bot connection.
BLUEBOT.GO
Executes commands stored in Blue-Bot's memory.
BLUEBOT.OPEN
Opens the connection to Blue-Bot.
BLUEBOT.RUN [list of commands]
Executes Blue-Bot commands.
BLUEBOT.STATUS
Reports status information about Blue-Bot.
BLUEBOT.WRITE procedure-name
Downloads a procedure to Blue-Bot.
BLUEBOT?
(BLUEBOTP) Tests if the Blue-Bot drivers are installed.

Objects

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.

.WHO
Reports a list of objects listening to commands.
ASK word runlist
ASK number runlist
ASK list runlist
Makes objects execute a list of commands.
CHECKTYPE value type
Checks an value for a type.
DECLARE kind name
(DCL) Creates an object.
EACH runlist
Applies a runlist to every object in the TELL list.
EVERY name
Outputs a list of objects.
IS.A object type
Checks an object for being of a specific type.
NEW kind
Creates a new Logo object.
TELL number
TELL object
TELL list
Defines a list of objects listening to commands.
TELLALL first last
Tells a range of turtle numbers.
TELLEVEN
Tells all turtles with even numbers.
TELLODD
Tells all turtles with odd numbers.
TYPEOF name
Reports the type of a name.
WHO
Reports a list of objects listening to commands.

Multimedia Commands

Multimedia commands.

PLAY filename
(PLAY filename TRUE)
(PLAY)
PLAY [list]
Plays sound files and lists of notes.

The Workspace

All kinds of commands related to the workspace.

ABOUT
User-supplied procedure to display an About box.
ALIAS old-name new-name
Defines alias names.
ASCII character
Converts a character into its ASCII value.
BYE
(QUIT, EXIT) Ends Logo.
CHAR number
Converts a number into a Unicode character.
CLEARTEXT
(CT) Clears the Listener pane.
DATE
Reports the date.
FULLSCREEN
(FS) Switches to the Full Screen perspective.
HELP commandname
Displays help for a command.
LOAD filename
LOAD filename.ext
(LOAD)
Loads a file into Logo.
MAKE name object
Assigns a value to a name.
MILLISECONDS
Outputs the number of milliseconds spent since January 1, 1970.
NAME object name
Assigns a value to a name.
QUOTE word
Quotes its input.
RECYCLE
(RECYCLE TRUE)
Starts the garbage collector.
RESTART
(RESTART TRUE)
Erases everything and restarts Logo.
SAVE filename
SAVE TRUE
(SAVE)
SAVE type-descriptors
Saves the workspace to disk.
SPLITSCREEN
(SS) Switches to the Split Screen perspective.
TEXTSCREEN
(TS) Switches to the Text Screen perspective.
THING word
Reports the value of a name.
TIME
Outputs the time.
VERINFO
Outputs Logo version information as a list.
VERSION
(VER) Outputs the Logo version.
WORKSPACE.VIEW
Switches to the Work perspective.

Window management

Management of windows.

Logo provides commands to set the active window and to move and resize windows.

ACTIVEWINDOW
(ACTIVEW) Reports the name of the active graphics window.
CLOSEWINDOW name
Closes a window.
SETACTIVEWINDOW windowname
(SETACTIVEW) Sets the name of the active window.
SETWINSIZE “windowname [width height]
Sets the size of a window.
SETWPOS windowname [x y]
Sets the position of a window.
SETWSIZE windowname [width height]
Sets the size of a floating window.
WINSIZE “windowname
Reports the size of a window.
WPOS windowname
Outputs the position of a window.
WSIZE “windowname
Reports the size of a window.

This section explains the command that you can use to modify the menu of Terrapin Logo. Note that these commands will not be available in future versions of Terrapin Logo.

APPENDMENU menuname
Appends a new menu.
APPENDMENUCOMMAND menuname itemname list
Appends a new menu item.
APPENDMENUITEM menuname itemname id
Appends a new menu item.
COMMAND number
Invoke a menu command by its ID number.
DELETEMENU name
Deletes a menu.
DELETEMENUITEM id
Deletes a menu item.
FINDMENUID menuname itemname
Finds the ID of a menu item.
ONCOMMAND id runlist
ONCOMMAND id []
Defines the commands that execute when a menu item is selected.

Other commands

This section contains commands that do not fit into any other category.

.WINDOWS [function-name DLL-name]
(.WINDOWS “function-name arguments)
Call a Windows system function (not available on the Mac).

Properties

logo/quickref.txt · Last modified: 2018/08/27 03:39 (external edit)