Programmer's Reference
Miscellaneous
You may place comments in rLogo programs by preceding
them with an apostrophe. Everything following an apostrophe on a line
is ignored. Example:
to test 'showing the use of comments
'This line will be ignored
fd 20 ' Move the turtle forward.
left 90 ' Then turn left.
end ' That's it!
rLogo Expressions may be built with the following
operators:
+ is Additon (5+3)
- is Subtraction (5-3)
* is Multiplication (5*3)
/ is Division (5/3)
Normally, rLogo evaluates multiplication, then division,
then addition, then subtraction; however, you may change this by using
parentheses:
show 5*5+2
show 5*(5+2)
rLogo supports the following LOGICAL operators:
(:x>:y) (x is greater than y)
(:x<:y) (x is less than y)
(:x=:y) (x is equal to y)
For LOGICAL AND, use '*'. Eg: ((:x>:y)*(:y<:z)) (x is greater than y
and y is less than z)
For LOGICAL OR, use '+'. Eg: ((:x>:y)+(:x=:y)) (x is greater than
or equal to y)
For LOGICAL NOT, use '~'. Eg: ~(:x>:y) (x is not greater than y)
Command Summary
The command summary uses the following conventions:
command,abbreviation "string parameters" (numeric parameters) [list
parameters] - explanation of the command.
Where:
command - specifies the rLogo Command
abbreviation - where applicable, specifies an easier to type abbreviation
for the command
"string parameters" - specifies that a word should follow.
(numeric parameter) - specifies that a number should follow
[list parameter] - specifies that a List should follow (all Lists must
be enclosed in [brackets] and may include one or more commands.)
Drawing
forward,fd (distance) - causes the Turtle to move forward the
specified number of units.
back,bk (distance) - causes the Turtle to move backwards the
specified number of units.
right,rt (angle) - causes the Turtle to turn right by the
specified number of degrees.
left,lt (angle) - causes the Turtle to turn left by the specified
number of degrees.
write "(message)" - prints a message on the screen, at the current
Turtle Position. Message should be enclosed in parentheses!
home - returns the Turtle to its home position, the center of the
screen.
hideturtle,ht - makes the Turtle Invisible
showturtle,st - makes the Turtle Visible
clearscreen,cs - clears the Output Window
penup,pu - "lifts" the Turtle's pen; it will not draw until
pendown is received.
pendown,pd - "lowers" the Turtle's pen; causes it to resume
drawing after a penup command was issued.
setpencolor,setpc (red) (green) (blue) - changes the pen color to
the specified color. (red), (green), and (blue) must range from 0 to 255.
setbackcolor,setbc (red) (green) (blue) - changes the background
color to the specified color. (red), (green), and (blue) must range from 0 to
255.
Flow Control
repeat (count) [instructionlist] - repeats the commands in the
[instruction list] the specified number of times.
ifelse (condition) [true_instructionlist] [false_instructionlist]
- Conditonally executes commands. If (condition) evaluates to true (a
non-zero value), the [true_instructionlist] is executed; otherwise, the
[false_instructionlist] is executed.
while (condition) [instructionlist] - executes the commands in
[instructionlist] as long as condition is true (non-zero). Be careful of
accidentally creating endless loops!
Visual Effects
manual - disables automatic screen refreshes. The turtle will
still draw, but the screen will not be updated until a paint or
auto command is issued.
auto - reenables automatic screen refreshes. Reverses the effect
of the manual command.
paint - forces an immediate screen refresh. Used in conjunction
with the manual command.
pause (duration)- pauses for the specified number of
milliseconds. There are 1000 milliseconds in a second, so pause
1000 causes a 1 second pause.
Programming
show ":variable" - outputs the value of the named variable to the
Command Box. Note that the variable name must be preceded by a
colon.
dump - dumps all procedures and variables into the Command Box,
suitable for copying and pasting into a text editor for permanent storage.
You may load this file later by pasting into the batch editor, or you
may use it with rLogo Runtime.
batch - invokes the Batch Editor, which loads and
immediately executes any commands that are typed or pasted into it.
end - has no effect during normal rLogo programming,
but is necessary to separate subroutines when using the Batch Editor or
rLogo Runtime.
params [parameter list]- used to specify parameters that must be
passed to a subroutine.
to "newcommand" - creates a new subroutine (or edits an existing
subroutine) with the specified name.
make "variable" (value) - assigns a value to a variable. Note that
the variable must be preceded by a colon when accessed, but a colon is not
used when assigning a value.