ProLOGO user manual

In Italiano

For more informations ProLOGO Home Page

ProLOGO is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License.

Install how-to

ProLOGO needs swi-prolog and XPCE libraries. These packages ara available for Linux and Windows and can be downloaded at swi-prolog homepage

For Debian-users:
apt-get install swi-prolog swi-prolog-doc swi-prolog-xpce

ProLOGO is distributed as a Prolog source, in two versions:
The first version comes with all the images of the turtle (359 images for 359 different headings)
The second version ("reduced") provides a Perl Script that creates the images. To make it work you have to install the program mogrify (ImageMagick). You can create all the images running the commands

./ruota.pl turtle.gif; ./ruota.pl pinguino.gif

Launching ProLOGO

At the prompt of prolog compile the program (by the command [logo].).
In Linux you have to start prolog by the command xpce which loads the XPCE libraries.

Example (Linux)

$ xpce
XPCE 6.0.1, February 2002 for i386-linux and X11R6
Copyright (C) 1993-2002 University of Amsterdam.
XPCE comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to redistribute it under certain conditions.
The host-language is SWI-Prolog version 5.0.0

For HELP on prolog, please type help. or apropos(topic).
         on xpce, please type manpce.

?- [logo].
Warning: (/home/lor/prolog/logo/logo.pl:37):
        Singleton variables: [C]
Warning: (/home/lor/prolog/logo/logo.pl:38):
        Singleton variables: [A, B]
Warning: (/home/lor/prolog/logo/logo.pl:300):
        Singleton variables: [L]
Warning: (/home/lor/prolog/logo/logo.pl:301):
        Singleton variables: [Head]
Warning: (/home/lor/prolog/logo/logo.pl:302):
        Singleton variables: [Nome]
Warning: (/home/lor/prolog/logo/logo.pl:306):
        Singleton variables: [OldValue]
Warning: (/home/lor/prolog/logo/logo.pl:318):
        Singleton variables: [Env]
Warning: (/home/lor/prolog/logo/logo.pl:345):
        Singleton variables: [Env]
Warning: (/home/lor/prolog/logo/logo.pl:350):
        Singleton variables: [X, F]
Warning: (/home/lor/prolog/logo/logo.pl:356):
        Singleton variables: [X, Parziale]
Warning: (/home/lor/prolog/logo/logo.pl:359):
        Singleton variables: [X, Parziale]
Warning: (/home/lor/prolog/logo/logo.pl:360):
        Singleton variables: [Env]
Warning: (/home/lor/prolog/logo/logo.pl:368):
        Singleton variables: [Env]
Warning: (/home/lor/prolog/logo/logo.pl:369):
        Singleton variables: [Env]
Warning: (/home/lor/prolog/logo/logo.pl:372):
        Singleton variables: [Env]
Warning: (/home/lor/prolog/logo/logo.pl:382):
        Singleton variables: [Env]
Warning: (/home/lor/prolog/logo/logo.pl:383):
        Singleton variables: [Env]
Warning: (/home/lor/prolog/logo/logo.pl:384):
        Singleton variables: [Env]
Warning: (/home/lor/prolog/logo/logo.pl:400):
        Singleton variables: [Env]
Warning: (/home/lor/prolog/logo/logo.pl:405):
        Singleton variables: [Env]
Warning: (/home/lor/prolog/logo/logo.pl:406):
        Singleton variables: [Env]
Warning: (/home/lor/prolog/logo/logo.pl:423):
        Singleton variables: [Env]
Warning: (/home/lor/prolog/logo/logo.pl:429):
        Singleton variables: [T]
Warning: (/home/lor/prolog/logo/logo.pl:430):
        Singleton variables: [F]
Warning: (/home/lor/prolog/logo/logo.pl:445):
        Singleton variables: [Env]
Warning: (/home/lor/prolog/logo/logo.pl:446):
        Singleton variables: [Env]
Warning: (/home/lor/prolog/logo/logo.pl:456):
        Singleton variables: [Nome, X]
Warning: (/home/lor/prolog/logo/logo.pl:457):
        Singleton variables: [Nome, X]
Warning: (/home/lor/prolog/logo/logo.pl:522):
        Clauses of instr/4 are not together in the source-file
Warning: (/home/lor/prolog/logo/logo.pl:536):
        Singleton variables: [Env]
Warning: (/home/lor/prolog/logo/logo.pl:543):
        Singleton variables: [I]
Warning: (/home/lor/prolog/logo/logo.pl:550):
        Singleton variables: [Lcs]
Warning: (/home/lor/prolog/logo/logo.pl:550):
        Clauses of instr/4 are not together in the source-file
Warning: (/home/lor/prolog/logo/logo.pl:563):
        Singleton variables: [L5]
Warning: (/home/lor/prolog/logo/logo.pl:612):
        Singleton variables: [Angle]
Warning: (/home/lor/prolog/logo/logo.pl:627):
        Singleton variables: [Angle]
Warning: (/home/lor/prolog/logo/logo.pl:661):
        Singleton variables: [X, Y, Angle]
Warning: (/home/lor/prolog/logo/logo.pl:663):
        Singleton variables: [File]
Warning: (/home/lor/prolog/logo/logo.pl:686):
        Singleton variables: [H]
Warning: (/home/lor/prolog/logo/logo.pl:713):
        Singleton variables: [Answer]
Warning: (/home/lor/prolog/logo/logo.pl:723):
        Singleton variables: [X]
Warning: (/home/lor/prolog/logo/logo.pl:737):
        Singleton variables: [X]
Warning: (/home/lor/prolog/logo/logo.pl:757):
        Singleton variables: [Turtle]
Warning: (/home/lor/prolog/logo/logo.pl:796):
        Singleton variables: [X]
Warning: (/home/lor/prolog/logo/logo.pl:801):
        Singleton variables: [X]
% logo compiled 0.03 sec, 78,084 bytes

Yes
?- logo.

Basic Commands

forward n
(fd, avanti, a) moves the turtle forward, in the direction that it's facing, by the specified distance (measured in pixels)
back n
(bk, indietro, i) moves the turtle back, in the direction that it's facing, by the specified distance (measured in pixels)
rightturn n
(right, rt, destra, d) turns the turtle clockwise by the specified angle, measured in degrees (1/360 of a circle).
leftturn n
(left, lt, sinistra, s) turns the turtle counterclockwise by the specified angle, measured in degrees (1/360 of a circle).
home
(tana) moves the turtle to the center of the screen. Equivalent to SETPOS [0 0] SETHEADING 0.
clearscreen
(cs, puliscischermo, ps) erases the graphics window and sends the turtle to its initial position and heading. Like HOME and CLEAN together.
clean
(pulisci) erases all lines that the turtle has drawn on the graphics window. The turtle's state (position, heading, pen mode, etc.) is not changed.
cleartext
(ct, puliscitesto, pt) clears the text screen
print <value>
(pr, stampa) Prints a value on the text screen
make varname <value>
(assegna, as) Assigns the value value to the variable named varname, which must be a word
penup
(pu, sulapenna, su) sets the pen's position to UP, the turtle won't draw any line
pendown
(pd, giulapenna, giu) sets the pen's position to DOWN, the turtle will draw while it moves
showturtle
(st, mostarta, mt) Make the turtle visible
hideturtle
(ht, nastarta, nt) Hides the turtle
setx x
(vaix) moves the turtle to the specified x
sety y
(vaiy) moves the turtle to the specified y

setxy x y, setpos list
(vaixy - vaipos) moves the turtle to the specified position. For setpos the list's length must be 2.
setheading n
(seth, angolo) turns the turtle to a new absolute heading. The input is a number, the heading in degrees clockwise from the positive Y axis.
setpencolor 0-7 | "colorname
(pencolor, setpc, color, colorepenna, colore) sets the pen color. The color can be a number between 0 and 7
 
0  black        1  blue         2  green        3  cyan
4  red          5  magenta      6  yellow       7 white
The color can be a name, for example "black or the hexadecimal description (ex. "#000000 )
setbgcolor 0-7 | "colorname
(setbackgroundcolor, bgcolor, coloresfondo, sfondo) sets background color
defaultcolors
(coloristandard) sets default colors (black on white)
printoutnames
(pons, ponames, showvars, mostravar) Shows the values of all definied variables
eraseall
(erall, cancellatutto) Erases the memory
label <word / list>
(etichetta) writes a text on graphics screen at the turtle position
load <list>
(carica) loads a script and executes it
about
(informazioni) shows info about prologo

Flow Control

repeat n [ instructions ]
(ripeti) Repeats n times the instructions
if condition [ instructions1 ] [ instructions2 ]
(se) if condition is true executes instructions1 else executes instructions2
while condition [ instructions ]
(mentre) repeats instructions while condition is true

Expressions

Data types are integers, words, lists and booleans.

Integers

Allowed operators: +, -, *, / (integer divisions), % (remainder)

These are integer expressions as well:

read
(leggi). This function (which can take a parameter, the message to display) returns an integer read by the user. It's not standard LOGO (but you can use first readlist instead)

first <list>
(primo) Returns the first element of a list
last <list>
(ultimo) Returns the last element of a list
xcor
Returns the current x of the turtle
ycor
Returns the current y of the turtle
heading
(direzione) outputs a number, the turtle's heading in degrees
length <list>, length <word>
(lunghezza, lungh) returns the length of a list (or word)

Lists

Lists are written into square parenthesys.
Expressions inside lists are not valutated. For example [1+2] is a list of three elements, 1, + and 2 and is not equal to [ 3 ]

You can use the operators push and concat to insert elements into lists and to append two lists.

readlist
(leggilista) Returns the list that the user writes as input

butfirst <list>
(coda) Returns the tail of the list (the list without its first element)
push <int/bool/word> <list>
(metti) Returns a list with the first argument inserted at the beginning of the second argument
concat <list1> <list2>
returns the list obtained by the concatenation of the two lists

Word

In LOGO a word is a string without spaces

A word is written as a string beginning with ". Ex: "string

It is possible to use first, last and butfirst on the words.

Booleans

A boolean expression can be true or false or the use of the operators =,<,<=,>,>=,!= on integer expressions, or empty <list>. Booleans can be connected by and, or, not


Lorenzo Masetti - Luca Cinti
Last modified: Wed Oct 1 19:40:53 CEST 2003