Terrapin Resources

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

Controls the conversion of quoted symbols to upper case.

Syntax

Description

:CASE controls the way quoted words are converted to upper case. If :CASE is TRUE, which is the default, Logo converts lowercase quoted words to upper case as they are input to Logo. If :CASE is set to FALSE, the case of quoted words is not changed.

Altering :CASE is the same as altering the CASE property of the “PREFS object.

Note that quoted words enclosed in vertical bars, or back-quoted words are not affected.

Example

PR “Hello HELLO MAKE “CASE FALSE PR “Hello Hello

:CURRENT.GRAPHICS

Contains the current graphics window name.

Syntax

Description

:CURRENT.GRAPHICS contains the name of the currently active graphics window. Logo has only one Graphics canvas, so :CURRENT.GRAPHICS always outputs GRAPHICS. This variable is read-only.

Example

:CURRENT.GRAPHICS Result: GRAPHICS

:DEFAULT.LAYOUT

Reports the default Logo panel layout

Syntax

Description

The built-in variable DEFAULT.LAYOUT reports the default layout of all Logo panels, which is the Graphics panel to the top left, the Listener panel to the bottom left, the Editor panel to the top right, and the Help panel to the bottom right.

The menu command Window/Original Logo Layout sets the default layout.

See also :LAYOUT and :INITIAL.LAYOUT.

MAKE “LAYOUT :DEFAULT.LAYOUT

:EPSILON

Contains the minimum value that two numbers may differ to still be considered to be equal.

Syntax

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 0, permitting an exact comparison. If you set the number to a small value between 0.1 and 1.0e-16, 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.

Example

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.

Syntax

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.

Syntax

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.

Example

TO TEST.ERROR CATCH “ERROR [1 / 0] (PRINT “|Error text:| :ERRORTEXT) END TEST.ERROR Error text: Division by Zero

:FENCE

Defines the way turtles bounce off the edges of the Graphics screen.

Syntax

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.

Example

:FENCE Result: WRAP

:INITIAL.LAYOUT

Reports or sets the initial Logo panel layout

Syntax

Description

The built-in variable INITIAL.LAYOUT controls the initial layout of all Logo panels. This is the layout of all Logo panels that Logo found after finishing its startup phase. This includes any changes made by an INIT.LGO file that was autoloaded from the classroom server, or any layout that was last saved with Logo’s Autosave functionality.

The menu command Window/Initial Layout also sets the initial layout.

See also :LAYOUT and :DEFAULT.LAYOUT.

MAKE “INITIAL.LAYOUT :LAYOUT

:LANGUAGE

Reports Logo’s UI language.

Syntax

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.

Example

:LANGUAGE Result: EN

:LAYOUT

Gets or sets the panel layout.

Syntax

Description

The LAYOUT variable contains a list that reflects the entire layout of all Logo panels. The list is a pair of values; the first value is the name of the panel, and the second value is a list containing the values of the panel’s LAYOUT and STATE properties. You can read this variable and store its value to save a layout, and set the variable back to the stored value to restore the layout at a later time.

The possible states are NORMAL, HIDDEN, MINIMIZED or MAXIMIZED.

Example

:LAYOUT Result: [GRAPHICS [[0 0 100 60] NORMAL] LISTENER [[0 60 100 40] NORMAL] TOOLBOX [[80 0 20 25] HIDDEN] FILES [[80 25 20 25] HIDDEN] HELP [[70 50 30 50] NORMAL] EDITOR [[10 10 50 50] NORMAL] ICONBAR [0 0 0 0] NORMAL ]

:LOGOENGINE

Contains the ID of the currently running Logo engine.

Syntax

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.

If the debugger dialog is active, you can set LOGOENGINE to the ID number of the engine that you would like to inspect. When you have LAUNCH multiple background programs, this is a very handy way to switch between these background engines during debugging, and to inspect the state of these engines.

Use LAUNCHED to obtain a list of all active background engine IDs.

Example

:LOGOENGINE Result: 0

:LOGO.ENV

Contains a property list of global program and system settings.

Syntax

Description

LOGO.ENV contains a property list of program and system settings. Click here for a complete list of properties.

Example

GPROP “LOGO.ENV “VERSION Result: 5

:MIDI.OUTPUT

Contains the name of the music synthesizer that Logo uses to play music.

Syntax

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.

Example

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

Syntax

Description

MIDI.OUTPUTS outputs a list of available MIDI synthesizers. Logo uses a MIDI synthesizer to play music commands.

See also Making Music.

Example

:MIDI.OUTPUTS Result: [SIMPLE WEB WEBHQ] MAKE “MIDI.OUTPUT “WEBHQ

:PICTURE.FORMAT

Contains the default file extension for graphics files.

Syntax

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.

Example

:PICTURE.FORMAT Result: PNG

:PRECISION

Sets the precision in which numbers are printed.

Syntax

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

Example

PI Result: 3.14 MAKE “PRECISION 15 PI Result: 3.14159265358979

:PREFS

System-wide properties.

Syntax

Description

The PREFS object contains a list of system-wide properties that control the look and feel of Logo. Click here for a complete list of these properties.

Example

GPROP “PREFS “PRECISION Result: 2

:PROMPT

Gets or sets the prompt for the Listener.

Syntax

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.

Example

MAKE “PROMPT [PLEASE ENTER YOUR ANSWER:]

:STANDARD.INPUT

The number of the input stream.

Syntax

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.

See also OPEN and CREATE.

Example

:STANDARD.INPUT Result: 0

:STANDARD.OUTPUT

The number of the output stream.

Syntax

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.

Example

:STANDARD.OUTPUT Result: 0

:TAB

Sets the tab stop position.

Syntax

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 TAB property at the :PREFS object.

Example

:TAB Result: 4

:TRACE

Controls the output of debugging information.

Syntax

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:

   
1 Procedure calls and the execution of procedures
2 Assignments to values
4 Assignments to properties

Do not confuse the built-in variable with the procedure TRACE. The variable :TRACE takes precedence over the TRACE command.

:USERNAME

Reports the user name for local storage.

Syntax

Description

:USERNAME reports the name of the user that Logo uses to address the browser’s local storage files. This makes it possible to have a separate storage area for each user. The files stored in the browser’s local storage are not visible on disk, but they remain accessible for as long as the user name exists.

If no user has been set, :USERNAME defaults to Guest User.