SLogo Basic Commands

Math Operations

Name Description
SUM num1 num2 returns sum of num1 and num2
DIFFERENCE num1 num2 returns difference of num1 and num2
PRODUCT num1 num2 returns product of num1 and num2
QUOTIENT num1 num2 returns integer quotient of num1 and num2
REMAINDER num1 num2 returns integer remainder on dividing num1 by num2. The result is the same sign as num2
MINUS num returns negative of num

Drawing Operations and Turtle Commands

Command Description
FORWARD dist
FD dist
moves the turtle forward by dist pixels
BACK dist
BK dist
moves the turtle backwards by the amount specified
LEFT degrees
LT degrees
turns the turtle counterclockwise by the specified angle
RIGHT degrees
RT degrees
turns the turtle clockwise by the specified angle
SETXY xcor ycor moves the turtle to an absolute screen position.
SETX xcor moves the turtle horizontally to a new absolute horizontal coordinate
SETY ycor moves the turtle vertically to a new absolute vertical coordinate.
HOME moves the turtle to the center of the screen (0 0)
XCOR returns the turtle's X coordinate
YCOR returns the turtle's Y coordinate
HEADING returns the turtle's heading in degrees
TOWARDS xcor ycor returns a heading the turtle should be facing to point from its current position to the given position
SHOWTURTLE
ST
makes the turtle visible
HIDETURTLE
HT
makes the turtle invisible
CLEAN clears the drawing area (the turtle's statistics do not reset)
CLEARSCREEN
CS
erases the drawing area and sends the turtle to the home position (Like CLEAN and HOME)
PENDOWN
PD
sets the pen's position to DOWN
PENUP
PU
sets the pen's position to UP
PENDOWNP
PENDOWN?
returns 1 (:TRUE) if the pen is down, 0 (:FALSE) if it's up.

Control Structures and Procedures

Command Description
REPEAT numOrVar [ instructionlist
]
runs instructionlist numOrVar times
IF varOrCommand [ instructionlist
]
if varOrCommand is not 0, run instructionlist
TO sub_name [
instructionlist
]
defines a new subroutine (command) named subr_name. When invoked, the subroutine will execute the body of instructions included in the definition.

Boolean Operations

Command Description
LESS? num1 num2 returns 1(:TRUE) if its first input is strictly less than its second, or 0 otherwise (:FALSE)
GREATER? num1 num2 returns 1 if its first input is strictly greater than its second, or 0 otherwise
EQUAL? thing1 thing2 returns 1 if the two inputs are equal, 0 otherwise
NOTEQUAL? thing1 thing2 returns 1 if the two inputs are not equal, 0 otherwise