SLogo Basic Commands
While the command names below are given in all capital letters, SLogo is not case sensitive and should accept any correct spelling of the command names. Note that any values used as parameters to a command may be the result of calling any of the commands below or a value stored in a variable. Thus all commands return a double value as described below. Also, commands can be formatted over any number of lines, including multiple commands on the same line, but each token is guaranteed to be separated by one or more spaces.
Basic Syntax
Token  Syntax  Semantics  Examples 

Constant  ?[09]+\.?[09]* 
any real valued number note, to avoid potential ambiguity in parsing there should not be a space between the negative sign and the value 
50 1.3

Variable  :[azAZ_]+ 
any word preceded by a colon, : note, if a variable name is used that has not previously been given a value, return a default value (i.e., 0) 
:distance :side 
Command  [azAZ_]+(\?)? 
any word can be a commandname note, all commands return a numeric value note, builtin commands are given below and userdefined commands cannot reuse those names 
forward fd 
List  [ 
these brackets enclose a list of zero or more commands or variables note, to make parsing easier, these will always be separated from other tokens by spaces 
[ fd 50 rt 90 ] 
Comment  ^#.* 
Ignore any lines that are empty, i.e., only zero or more spaces, and lines that begin with the comment character, "#".  # a comment #fd 50 
Turtle Commands
Name(s)  Description 

FORWARD pixels FD pixels 
moves turtle forward in its current heading by pixels distance returns the value of pixels 
BACK pixels BK pixels 
moves turtle backward in its current heading by pixels distance returns the value of pixels 
LEFT degrees LT degrees 
turns turtle counterclockwise by degrees angle returns the value of degrees 
RIGHT degrees RT degrees 
turns turtle clockwise by degrees angle returns the value of degrees 
SETHEADING degrees SETH degrees 
turns turtle to an absolute heading returns number of degrees moved 
TOWARDS x y  turns turtle to face the point (x, y), where (0, 0) is the center of the screen returns the number of degrees turtle turned 
SETXY x y GOTO x y 
moves turtle to an absolute screen position, where (0, 0) is the center of the screen returns the distance turtle moved 
PENDOWN PD 
puts pen down such that when the turtle moves, it leaves a trail returns 1 
PENUP PU 
puts pen up such that when the turtle moves, it does not leave a trail returns 0 
SHOWTURTLE ST 
makes turtle visible returns 1 
HIDETURTLE HT 
makes turtle invisible returns 0 
HOME  moves turtle to the center of the screen (0 0) returns the distance turtle moved 
CLEARSCREEN CS 
erases turtle's trails and sends it to the home position returns the distance turtle moved 
Turtle Queries
Name  Description 

XCOR  returns the turtle's X coordinate from the center of the screen 
YCOR  returns the turtle's Y coordinate from the center of the screen 
HEADING  returns the turtle's heading in degrees 
PENDOWN? PENDOWNP 
returns 1 if turtle's pen is down, 0 if it is up 
SHOWING? SHOWINGP 
returns 1 if turtle is showing, 0 if it is hiding 
Math Operations
Name  Description 

SUM expr1 expr2 + expr1 expr2 
returns sum of the values of expr1 and expr2 
DIFFERENCE expr1 expr2  expr1 expr2 
returns difference of the values of expr1 and expr2 
PRODUCT expr1 expr2 * expr1 expr2 
returns product of the values of expr1 and expr2 
QUOTIENT expr1 expr2 / expr1 expr2 
returns quotient of the values of expr1 and expr2 
REMAINDER expr1 expr2 % expr1 expr2 
returns remainder on dividing the values of expr1 by expr2 
MINUS expr ~ expr 
returns negative of the values of expr 
RANDOM max  returns random nonnegative number strictly less than max 
SIN degrees  returns sine of degrees 
COS degrees  return cosine of degrees 
TAN degrees  returns tangent of degrees 
ATAN degrees  returns arctangent of degrees 
LOG expr  returns natural log of expr 
POW base exponent  returns base raised to the power of the exponent 
PI  Reports the number Pi 
Boolean Operations
Name  Description 

LESS? expr1 expr2 LESSP expr1 expr2 
returns 1 if the value of expr1 is strictly less than the value of expr2, otherwise 0 
GREATER? expr1 expr2 GREATERP expr1 expr2 
returns 1 if the value of expr1 is strictly greater than the value of expr2, otherwise 0 
EQUAL? expr1 expr2 EQUALP expr1 expr2 
returns 1 if the value of expr1 and the value of expr2 are equal, otherwise 0 
NOTEQUAL? expr1 expr2 NOTEQUALP expr1 expr2 
returns 1 if the value of expr1 and the value of expr2 are not equal, otherwise 0 
AND test1 test2  returns 1 if test1 and test2 are nonzero, otherwise 0 
OR test1 test2  returns 1 if test1 or test2 are nonzero, otherwise 0 
NOT test  returns 1 if test is 0 and 0 if test is nonzero 
Variables, Control Structures, and UserDefined Commands
Name  Description 

MAKE variable expr SET variable expr 
assigns the value of expr to variable, creating the variable if necessary returns expr 
REPEAT expr [ command(s) ]  runs command(s) given in the list the value of expr number of times returns the value of the final command executed (or 0 if no commands are executed) note, the value of the current iteration, starting at 1, is automatically assigned to the variable :repcount so that it can be accessed by the command(s) 
DOTIMES [ variable limit ] [ command(s) ] 
runs command(s) for each value specified in the range, i.e., from (1  limit) inclusive returns the value of the final command executed (or 0 if no commands are executed) note, variable is assigned to each succeeding value so that it can be accessed by the command(s) 
FOR [ variable start end increment ] [ command(s) ] 
runs command(s) for each value specified in the range, i.e., from (start  end), going by increment returns the value of the final command executed (or 0 if no commands are executed) note, variable is assigned to each succeeding value so that it can be accessed by the command(s) 
IF expr [ command(s) ]  if expr is not 0, runs the command(s) given in the list returns the value of the final command executed (or 0 if no commands are executed) 
IFELSE expr [ trueCommand(s) ] [ falseCommand(s) ] 
if expr is not 0, runs the trueCommands given in the first list, otherwise runs the falseCommands given in the second list returns the value of the final command executed (or 0 if no commands are executed) 
TO commandName [ variable(s) ] [ command(s) ] 
assigns command(s) given in the second list to commandName using parameters given in first list as variables when commandName is used later in a program, any given values are assigned to variables that can be accessed when the command list is run and the value of the final command executed is returned (or 0 if no commands are executed) returns 1 if command is successfully defined, otherwise 0 