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.
:CASE
Makes Logo convert its input to upper case or not; no inputs.
Syntax
MAKE "CASE TRUE-or-FALSE
:CASE
Description
:CASE causes Logo to convert all input to upper case if set to TRUE, except for words that are enclosed in vertical bars or back quotes. If :CASE is FALSE, Logo does not convert any input to upper case. When Logo starts, it sets :CASE to TRUE. Instead of setting the variable :CASE, you can also set the PREFS/CASE property of the “PREFS object.
Important: If you set :CASE to FALSE, all commands must be entered in UPPER CASE! Also, the case of all names and properties must remain in UPPER CASE.
Examples
MAKE “CASE FALSE PARSE “lower Result: [lower] make “a 5 Error: make is not a procedure name MAKE “CASE TRUE PARSE “lower Result: [LOWER]
:CURRENT.GRAPHICS
Contains the current graphics window name; no inputs.
Syntax
:CURRENT.GRAPHICS
Description
:CURRENT.GRAPHICS contains the name of the currently active graphics window. Logo has only one Graphics panel, so :CURRENT.GRAPHICS always outputs GRAPHICS. This variable is read-only.
Examples
:CURRENT.GRAPHICS Result: GRAPHICS
:EPSILON
Contains the minimum value that two numbers may differ to still beconsidered to be equal; no inputs.
Syntax
MAKE "EPSILON number
:EPSILON
Description
Computer floating point numbers are based on the binary system. If used in the decimal system, they quickly introduce tiny rounding differences caused by the conversion between the decimal and binary formats. Therefore, comparing two numbers for equality may fail unexpectedly. The :EPSILON variable contains the minimum value that two numbers may differ to still be considered to be equal.
Initially, :EPSILON is set to 1.0e-15, permitting an exact comparison. If you set the number to a small value between 0.1 and 1.0e-15, Logo would perform the expression (ABS :A :B) < :EPSILON instead to determine if two numbers are equal.
It may be beneficial to use :EPSILON together with the :PRECISION variable. The initial value of :PRECISION is 2, causing numbers to be printed with two decimal places. A matching value for :EPSILON would, therefore, be 0.001.
Examples
MAKE “EPSILON 0.001 0.001 = 0.0011 Result: TRUE 0.001 = 0.002 Result: TRUE 0.001 = 0.003 Result: FALSE MAKE “EPSILON 0
:ERROR
Contains the type of the last runtime error; no inputs.
Syntax
:ERROR
Description
The built-in variable ERROR works together with the CATCH and THROW commands. Whenever Logo throws a word with the THROW command inside the instruction list of a CATCH command, or Logo throws a runtime error, and that error or word is caught, Logo sets :ERROR to the tag of the caught error. The CATCH command sets the variable to the empty list before executing its instruction list. Please note that there is a command ERROR that outputs more detailed information about an error.
Runtime errors set this variable to RUNTIME.
:ERRORTEXT
Reports the text of the last caught runtime error or THROWn word; no inputs.
Syntax
:ERRORTEXT
Description
The built-in variable ERRORTEXT works together with the CATCH and THROW commands. Whenever Logo throws a word with the THROW command inside the instruction list of a CATCH command, or Logo throws a runtime error, and that error or word is caught, Logo sets ERRORTEXT to the text of the runtime error, or to Uncaught THROW: xxx, where xxx is the tag that THROW threw. The CATCH command sets the variable to the empty list before executing its instruction list.
See also ERROR.
Examples
TO TEST.ERROR CATCH “ERROR [1 / 0] (PRINT “|Error text:| :ERRORTEXT) END Result: TEST.ERROR defined TEST.ERROR Result: Division by Zero
:FENCE
Defines the way turtles bounce off the edges of the Graphics screen; no inputs.
Syntax
MAKE "FENCE value
:FENCE
Description
There are four ways a turtle can react when it hits the bounds of the Graphics drawing area (see also SETBOUNDS). It can simply ignore the boundaries (WINDOW), it can stop moving (FENCE), it can bounce off the border (BOUNCE), or it can wrap around and re-enter the window on the opposite side (WRAP). The behavior is defined by setting the variable :FENCE to one of these values. The commands WINDOW, FENCE, BOUNCE and WRAP all set the :FENCE variable.
Examples
:FENCE Result: WRAP
:LANGUAGE
Reports Logo’s UI language; no inputs.
Syntax
:LANGUAGE
Description
:LANGUAGE reports the language identifier of the language used by Logo’s user interface (UI). If Logo is in English, :LANGUAGE reports “EN_US”, for example.
Examples
:LANGUAGE Result: EN
:LAYOUT
Gets or sets the panel layout; no inputs.
Syntax
MAKE "LAYOUT list
:LAYOUT
Description
The LAYOUT variable contains a list that reflects the entire layout of all Logo panels. It is a three-element list. The first element is the name of the left panel, and the third element is the name of the right panel. Both panels can also be another three-element list, which creates another split panel inside the respective place.
The middle value is the splitter value. This is either V or H for a vertical or horizontal splitter, followed by a number which is the percentage that the top or left panel occupies. If you use “px” as the suffix, the top or left panel will have a fixed width (or height) of these pixels, and the splitter will be immoveable. Examples are V50
for a vertical splitter with 50% for each panel, or H40
for a horizontal splitter with 40% for the top and 60% for the bottom panel
The variable also accepts several predefined values for the layout. See the “Select a View” dialog for these names.
Please note the Classic Logo reports a different layout structure.
Examples
:LAYOUT Result: [[GRAPHICS H60 LISTENER] V60 EDITOR]
:LOGO.ENV
Contains a property list of global program and system settings; no inputs.
Syntax
PLIST "LOGO.ENV
Description
LOGO.ENV contains a property list of program and system settings. See the LOGO.ENV object for a complete list of properties.
Examples
GPROP “LOGO.ENV “VERSION Result: 5
:LOGOENGINE
Contains the ID of the currently running Logo engine; no inputs.
Syntax
:LOGOENGINE
Description
:LOGOENGINE contains the ID number of the currently executing Logo engine. In most cases, this is the value 0 for the main Logo engine. If you use this value in a LAUNCHed background program, however, the variable contains the ID number of the engine that runs the Logo background program. The same is true for Logo event handlers.
In a background program, you can use that ID number to terminate the program using the HALT command, like HALT :LOGOENGINE
. The main Logo engine has an ID of 0.
Examples
:LOGOENGINE Result: 0
:MIDI.OUTPUT
Contains the name of the music synthesizer that Logo uses to play music; no inputs.
Syntax
MAKE "MIDI.OUTPUT name
:MIDI.OUTPUT
Description
MIDI.OUTPUT contains the name of the music synthesizer that Logo uses to play music. It is one of the names that the :MIDI.OUTPUTS variable returns.
Examples
:MIDI.OUTPUT Result: WEB :MIDI.OUTPUTS Result: [SIMPLE WEB WEBHQ] MAKE “MIDI.OUTPUT “WEBHQ
:MIDI.OUTPUTS
Returns a list of synthesizer names that Logo supports for playing music; no inputs.
Syntax
:MIDI.OUTPUTS
Description
MIDI.OUTPUTS outputs a list of available MIDI synthesizers. Logo uses a MIDI synthesizer to play music commands.
See also Making Music.
Examples
:MIDI.OUTPUTS Result: [SIMPLE WEB WEBHQ] MAKE “MIDI.OUTPUT “WEBHQ
:PICTURE.FORMAT
Contains the default file extension for graphics files; no inputs.
Syntax
MAKE "PICTURE.FORMAT value
:PICTURE.FORMAT
Description
The built-in variable :PICTURE.FORMAT contains the default file extension for graphics files when no file extension is given. It should be set to any graphics file extension that your browser can load. On startup, the value is set to PNG.
Examples
:PICTURE.FORMAT Result: PNG
:PRECISION
Sets the precision in which numbers are printed; no inputs.
Syntax
MAKE "PRECISION number
:PRECISION
Description
PRECISION is a pre-defined name that sets the number of decimal places displayed in Logo calculations. The default value of PRECISION when Logo is loaded is 2, the maximum allowed number is 15. Calculations are always performed using the full value of the number, regardless of the value of PRECISION. Another way to set the precision is to set the PREFS/PRECISION property of the “PREFS object.
Logo always strips trailing zeroes from a number. If :PRECISION is set to 2, the number 2 prints as “2”, not “2.00”.
Examples
PI Result: 3.14 MAKE “PRECISION 15 PI Result: 3.14159265358979
:PREFS
System-wide properties; no inputs.
Syntax
GPROP "PREFS "propertyname
PPROP "PREFS "propertyname value
PLIST "PREFS
Description
The PREFS object contains a list of system-wide properties that control the look and feel of Logo.
Examples
GPROP “PREFS “PRECISION Result: 2
:PROMPT
Gets or sets the prompt for the Listener; no inputs.
Syntax
MAKE "PROMPT text
:PROMPT
Description
PROMPT is a small text field in front of the Listener. When setting PROMPT, the text is displayed in that field as a prompt. Setting PROMPT to a list strips the brackets from the list and converts the list to a word.
Examples
MAKE “PROMPT [PLEASE ENTER YOUR ANSWER:]
:STANDARD.INPUT
The number of the input stream; no inputs.
Syntax
MAKE "STANDARD.INPUT channel
:STANDARD.INPUT
Description
STANDARD.INPUT is a pre-defined name that controls the source of the standard Logo input stream. When Logo starts up, the default value of STANDARD.INPUT is 0, which means that all Logo commands use the Listener for input and output. To change the source of the input stream to a file, the file must be opened or created to prepare it for input, and STANDARD.INPUT assigned the channel number with the value that the OPEN command returned.
Examples
:STANDARD.INPUT Result: 0
:STANDARD.OUTPUT
The number of the output stream; no inputs.
Syntax
MAKE "STANDARD.INPUT channel
:STANDARD.INPUT
Description
STANDARD.OUTPUT is a pre-defined name that controls the destination of the standard Logo output stream. When Logo starts up, the default value of STANDARD.OUTPUT is 0, which means that all Logo output is written to the Listener. To change the destination of the output stream to a file, the device must be opened or created to prepare it for output, and STANDARD.OUTPUT assigned the channel number which the value that the OPEN command returned.
To redirect Logo’s input stream, use :STANDARD.INPUT. See also OPEN and CREATE.
Examples
:STANDARD.OUTPUT Result: 0
:TAB
Sets the tab stop position; no inputs.
Syntax
MAKE "TAB number
:TAB
Description
The system variable TAB sets the tab stop width used in the Editor and Listener windows. This width is pre-set to 4 at startup. The value is saved when Logo exits and restored when Logo starts. Setting TAB is equivalent to setting the PREFS/TAB property at the PREFS object.
Examples
:TAB Result: 4
:TRACE
Controls the output of debugging information; no inputs.
Syntax
MAKE "TRACE number
:TRACE
Description
TRACE is a pre-defined name that allows monitoring of procedure or command line execution. TRACE displays each step of a procedure in the Listener without pausing as it is run. TRACE can be assigned a combination of the following values:
Value | Description |
---|---|
0 | No tracing |
1 | Trace procedure calls |
2 | Trace assignments to values |
4 | Trace assignments to properties |
Do not confuse the built-in variable with the procedure TRACE. The variable :TRACE takes precedence over the TRACE command.