Terrapin Resources

Terrapin Logo 4 has been discontinued! Our new Terrapin Logo version is much more powerful and modern; we strongly recommend that you update to our latest release of the Logo programming language.

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.

Syntax

Description

ALLTURTLES outputs a list of the names of every turtle that currently defined in Logo. ALLTURTLES is equivalent to the command EVERY “TURTLE.

Example

ALLTURTLES Result: [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]

CTURTLES

Arranges turtles in a circle.

Syntax

Description

CTURTLES activates and makes visible the number of turtles specified by its input and arranges them in a circle in the center of the Graphics window. Executing this command resets all turtles to their original shape. See also LTURTLES.

Example

DRAW CTURTLES 16 FD 100

LTURTLES

Arranges turtles in a row.

Syntax

Description

LTURTLES activates and makes visible the number of turtles specified by its input and arranges them in a horizontal line along the center of the Graphics window. Executing this command resets all turtles to their original shape. See also CTURTLES.

Example

DRAW LTURTLES 15 FD 100

SETTURTLES

Also: SETT

Creates a range of turtles.

Syntax

Description

SETTURTLES defines the total number of turtles available. Their numbers range from 0 to the input of SETTURTLES minus 1. For example, SETTURTLES 16 will create the turtles [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]. By default, Logo starts with 16 turtles defined and turtle 0 activated.

SETTURTLES creates turtles with the following characteristics:

   
Position Home [0 0]
Turtle size 1
Heading 0
Line width 1
Color 0 (black)
Turtle speed 1
Visibility FALSE
Pattern 0
Pen state PENDOWN
Font: Default system font, 9 points

SETTURTLES accepts any number as input. The actual maximum of turtles depends on the speed of the computer. Therefore, SETTURTLES sets the maximum number of turtles that you can define to 99, although you could use the DECLARE command to create more.

TURTLES reports the number of turtles that have been defined with SETTURTLES. Use the TELL, ASK, EACH, and WHO commands to access multiple turtles.

Example

SETTURTLES 4 TURTLES Result: 4

SETTURTLENAME

Also: SETTNAME

Sets the name of a turtle.

Syntax

Description

TURTLE name sets the name of the turtle whose object name is supplied as its first input. It also sets the turtle’s TOOLTIP property.

To get the turtle name, see TURTLENAME.

Example

SETTNAME 0 “JOE TNAME Result: JOE

SETTWINDOW

Attaches a turtle to a Graphics window.

Syntax

Description

SETTWINDOW attaches all active turtles, controls, and bitmaps to a window. Its input is the name of the window in which those objects should appear. Using an empty list as the window name detaches all active objects from their windows, making them invisible.

Use the TWINDOW command to retrieve the name of the window of the first active turtle, control, or bitmap.

Example

SETTWINDOW “GRAPHICS

TURTLENAME

Also: TNAME

Gets the name of the first active turtle.

Syntax

Description

TURTLENAME outputs the name of the first active turtle. This is also the value of its NAME property.

To set the turtle name, see SETTURTLENAME.

Example

SETTNAME 0 “JOE TNAME Result: JOE

TURTLENAMES

Also: TNAMES

Outputs a list of all turtle names.

Syntax

Description

TURTLENAMES outputs a list of the names of all turtles.

See also TURTLENAME and SETTURTLENAME.

Example

TURTLENAMES Result: [TURTLE.10 TURTLE.11 TURTLE.12 TURTLE.13 TURTLE.14 TURTLE.15 TURTLE.0 TURTLE.1 TURTLE.2 TURTLE.3 TURTLE.4 TURTLE.5 TURTLE.6 TURTLE.7 TURTLE.8 TURTLE.9]

TURTLES

Reports the number of turtles.

Syntax

Description

The TURTLES command reports the total number of available turtles. Set the number of turtles with SETTURTLES. See also TELLALL, ALLTURTLES, TELLEVEN, and TELLODD.

Example

TURTLES Result: 16

TWINDOW

Outputs the name of the window of the first active turtle.

Syntax

Description

TWINDOW outputs the name of the window to which the first active turtle, control, or bitmap is attached. If the turtle is not attached to any window, its output is the empty list. This command is equivalent to the command GPROP FIRST WHO “WINDOW.

Use the SETTWINDOW command to attach a turtle, a control, or a bitmap to a window.

Example

TWINDOW Result: GRAPHICS