Logo uses the same syntax as C, C++, Java and Javascript .
There are three types of instructions ( functions or procedures ) :
a) instructions returning a value, b) instructions not returning a
value, c) control instructions. Another section deals with comments (
section d) ).
a) Instructions
not returning a value
****************************************
To carry out an instruction, write it out in the console, as
follows :
forward();
The semi-colon is mandatory. You can also write:
forward(10);
The number "10" is a parameter. The default parameter for the
instruction forward(); is 10. You can choose the value of the
parameter, within certain limits, and write, for example :
forward(20);
The name of an instruction must start with a letter and be
continued by letters, spaces and numbers ( with a maximum of 255
characters ). You cannot use the symbols : - + = / % ? & | ^ '
".
Note: Logo cannot distinguish caps from small case letters or
whether there are letters with accents ( as in foreign languages like
é or ñ) or not. Logo ignores spaces. The following are
identical as far as Logo is concerned :
forward();
förward();
ForWard();
For Ward ( );
Forwárd();
After typing the instruction in the console, hit the return
key and the instruction will be carried out. You can write many
instructions in a row, and they will be carried out one after the
other :
forward();forward();forward();
Many variables are already created in Logo ( see the list at the end
of this section ). You can create your own variables by giving them a
value. For example, "lala" can be created and given the value "10"
with the following instruction :
lala = 10;
However, you can't write
10 = lala;
since " 10 " is not a variable.
The variables can be given a non-numerical value by placing the value
within quotation marks.
lala = "Hello, Goodbye";
The value of a variable can be another variable, if the previous one
has been defined, i.e. it had been given a value :
You can put a variable equal to another :
ball = lala;
With what has been written so far, the value of "ball" is "Hello,
Goodbye". If you write
ball = "lala";
the value of "ball " becomes the word "lala".
You can use a variable instead of a value for an instruction. For
example,
forward(30);
is equivalent to :
hehe = 30;
forward(hehe);
You cant write however
forward("hehe");
since youll get a error message, because the instruction
forward(); accepts only numerical variables or numerical
parameters.
You can have mathematical expressions to define variables. For
example :
hehe = 12 - 3;
The variable "hehe" will have the value 9. Another correct expression
is :
hehe = 12;
boulet = 3;
hehe = hehe - boulet;
the variable "hehe" takes on the value 9. Only
operator is accepted per instruction.
The following instruction will produce an error :
hehe = (12+2)*8;
One must write :
hehe = (12+2);
hehe = hehe*8;
Addition +
Division /
Subtraction -
Multiplication *
Modulo %
Note: Mudulo is the remainder of a division by an integer. You
can use + as an operator with a string of characters.