Slogo

{ This file contains most of the article text of the Slogo
  series which was printed in ZX Computing over three
  issues, from June/July to October/November 1984. I've
  left out all the bits describing how to enter the
  programs. Most of the text, however, explains how to use
  the Slogo system; all of this is below. Obvious typos
  have been silently corrected.
    Here and there I've inserted remarks between curly
  brackets, like this one, indicating where I've changed a
  few words for the sake of this text's consistency, and
  where necessary explaining how my type-up of the code
  differs from the exact description in the text. I've also
  added a few bits of ASCII art in a (fairly inadequate)
  attempt to replace the graphics that accompanied the
  articles.
    You should find two TZX files accompanying this text.
  One, Slogo.tzx, contains the main program and a few
  sample Logo programs. The other, Slogo parts.tzx,
  contains the individual listings from the three parts.
  This is of particular interest for those of you
  interested in emulating 16k Speccies, since those will
  only run Part 1 on its own. The completed program won't
  fit. 
                                 Richard Bos, Dec. 2011 }

-----------------------------------------------------------
David Nowotnik presents {...} a fascinating language.
-----------------------------------------------------------

LOGO was designed to provide children with an early 
introduction to computer programming and to develop their
abilities in logical thinking. The commands of LOGO are
simple to understand, yet LOGO encourages a good program-
ming style by virtue of its structure. LOGO is best known
as a graphics language, enabling still (and animated)
pictures and patterns to be drawn. More powerful versions
of LOGO have facilities for text handling as well as
graphics but my version, in common with most, deals with
graphics only.
   You'll find LOGO a very useful language if you have
young children, if you want a versatile graphics routine or
if you want to move on from BASIC. LOGO is an easy language
to learn, yet introduces you to structured programming, as
used by more powerful languages such as FORTH.
   Drawing with LOGO makes use of a turtle - but before you
rush off with complaints to the RSCPA, these are only
imaginary animals! Imagine you had precise control over the
movements of your turtle; instructing it to go forward or
back, turn left or right, all by specified amounts. Your
turtle carries a pen which you can instruct to be lowered
onto a sheet of paper, so that, as the turtle moves {makes
fist with left hand, puts right palm on it}, a line is
drawn. Using combinations of the four movement commands
(forward, back, left and right) drawings and patterns can
be created.
   Some versions of LOGO actually make use of a robotic
'turtle' which is interfaced to a computer. LOGO commands
are transmitted to the turtle, creating shapes on a sheet
of paper placed on the floor. More often, the monitor or TV
screen forms the paper and an electronic turtle is drawn
and is moved, on the screen. This is how my version works.
   Ideally, a LOGO translation program should be written in
machine code for a fast operating speed. I've written my
version in BASIC as it's easier for me to write it, and
easier for you to type in. But in using BASIC, speed is
lost - that's why I've called my version of this language
SLOGO!

RUN the program and you'll see the turtle on the screen. It
is represented by the "/\"; the point is its head and this
indicates the direction of the turtle. You'll see that the
turtle's starting point is at the centre of the screen,
heading directly up the screen.
   At the bottom of the screen you'll see "W:" and a
flashing cursor. This tells you that the computer is
waiting for you to enter a command. At this stage {Part 1
on Slogo parts.tzx}, this LOGO program will accept only
8 commands as shown in Fig. 1-2. {See below each part for
the tables and ASCII art going with it.} Note that all
commands are entered in capital letters (CAPS LOCK mode is
automatically set by the program) {Not true in the versions
on the TZXes - your humble typist is allergic to all-caps,
and has inversed all this to require (and set) caps lock
off. You may even find the resulting Logo code more 
legible - I know I do. I have left the commands and abbre-
viations in the text as is, though.} and for some commands,
a two letter abbreviation can be used instead of the full
word. Before you use any command, I'll describe what each
one will do.

HOME     This moves the turtle from anywhere on the screen
         back to its starting position at the centre of the
         screen, heading directly up the screen.
DRAW     This clears the screen, then moves the turtle
         HOME.
FORWARD  The turtle is moved forward a specified amount. To
         complete the command, you have to tell the turtle
         how far to move forward, eg FORWARD 20 (or FD 20).
         The unit of distance is one pixel; remember, the
         screen is made up of 256 pixels across, and 176
         down.
BACK     The turtle is turned head-to-tail, then moved in
         the same way as FORWARD (eg BACK 25).
LEFT     The turtle's head remains in the same place but
         its body will swivel so that its direction rotates
         to the left. You have to tell the turtle how far
         to turn. As do FORWARD and BACK, the command LEFT
         requires a number added to it to complete the
         instruction, to tell the turtle how much to turn.
         This number is the angle of turn in degrees. If
         you've forgotten that 90 degrees makes a right
         angle, then use Fig 1-3 as a guide when using the
         LEFT (or RIGHT) command. Angles should be whole
         numbers between 0 and 360.
RIGHT    This is the same principle as LEFT, but, of
         course, the turtle turns right instead of left.
PENUP    This command raises the pen from the paper so that
         the turtle can be moved without a line being
         drawn.
PENDOWN  The pen is placed on the paper.

Now, let's try a few examples. Type in:

FORWARD 40 (or FD 40), and press enter. You'll see the
turtle disappear, a line 40 pixels long will be drawn, and
then the turtle reappears. To enable the program to work as
quickly as possible, our turtle will always disappear when
in motion and will only reappear when all instructions are
complete and the "W:" symbol comes back on the screen.
Also, notice that when the program starts, the pen is in
the down position, enabling a line to be drawn.
   Now, let's turn the turtle 90 deg. to the right.
Type in:

RIGHT 90 (or RT 90) and press enter.
Then to move forward again:

FD 40.

If you continued entering alternatively RT 90 and FD 40,
you would end up with a square. As it is cumbersome to
type in one command at a time, LOGO allows you to string
commands together. Let's see how. First, clear the screen,
and reset the turtle using the command DRAW, then enter:

FD 40 RT 90 FD 40 RT 90 FD 40 RT 90 FD 40 RT 90 and enter.

Leave a single space between each command and number. This,
again, draws a square. You may have noticed that we are
repeating the same two commands four times. Fortunately,
LOGO allows repetition of commands to be simplified and
it's one of the things I'll be dealing with next time.
   What should happen if the turtle goes off the screen?
Let's find out. Clear the screen with DRAW, then enter:

RT 10 FD 2000

The turtle is turned slightly to the right, then moves
forward 2000 pixels. As it disappears off the edge of the
screen, our turtle reappears on the other side. This
feature is called wrap. It is useful to draw special
patterns and means that you won't get an error message if
you accidentally go off the edge of the screen.
   Another feature of this LOGO program is that the
specified number used by FORWARD, BACK, RIGHT and LEFT can
be replaced by a random number. As an example, try:

FD RANDOM 50

The turtle will move forward by an amount somewhere between
0 and 50.


Figures for part 1:

{ Fig. 1-1 was the listing. }


 Command     Two letter
            abbreviation
 draw
 home
 forward        fd
 back           bk
 left           lt
 right          rt
 penup          pu
 pendown        pd

Fig. 1-2. The LOGO commands featured in this {part}


         __ Starting  __
       --   direction   --
 Left/                     \Right
   /            A            \
  |     45      |      45     |
 /         \    |    /         \
 |           \  |  /           |
 V             \|/             V
     90 --------*-------- 90
               /|\
             /  |  \
           /    |    \
       135      |      135

               180
               Ends

Fig. 1-3. A diagram of angles to turn the turtle


-----------------------------------------------------------


In this {part}, I'll be expanding the number of instruc-
tions you can give to the turtle, turning this program into
a quite powerful and versatile version of LOGO.
   Take a look at fig. 2-2. This table gives you a list of
all the extra LOGO commands that will be introduced to you
in this {part}. As I warned {above, the program "parts 1+2"
on Slogo parts.tzx} will only fit on a 48k Spectrum.
   When you RUN the program, you should get the same
response as before: a "W:" prompt message at the base of
the screen, and the turtle ("/\") at the centre of the
screen. If you can recall from {above}, we have already
used the commands FORWARD, BACK, LEFT and RIGHT to move the
turtle, and DRAW, HOME, PENUP and PENDOWN as additional
control instructions. Let's have a look at the first six of
the new instructions, which also happen to be the simplest.
   So far, all our drawings have been made using black
'ink' on white 'paper'. The command PENCOLOUR (or PC)
allows you to change colours at any time. To complete the
PENCOLOUR command, you have to add a number, 0 to 7, accor-
ding to the number keys on your Spectrum. For example,
PENCOLOUR 1 will change the foreground colour to blue for
subsequent movements of the turtle.
   {Above}, I introduced the concept of wrap. This is when
an instruction to the turtle causes it to 'fall off' the
edge of the screen. With wrap, the turtle will re-appear on
the opposite side of the screen, and continue on its way.
You can forbid the turtle to wrap round using the command
NOWRAP. After using NOWRAP, if you accidentally command the
turtle to go off the edge of the screen, you will get an
error message. To reinstate the wrapping facility, use the
command WRAP.

 Turning Turtle

The last three instructions of the first group are very
straightforward. COPY will produce a copy of your screen
display on the printer, SAVE allows you to save the program
(I will deal with creating a LOGO program {below}) on tape,
and STOP simply stops the LOGO program, and hands you back
to BASIC. Remember with all LOGO commands to type them out
in full (do not use the equivalent BASIC keywords - LOGO
won't recognise them), or use the two letter abbreviation,
if one is available.
   The next group of instructions all start with SET, and
they move the turtle in a precise way. If you look in your
Spectrum handbook (on page 121), you'll find out how high
resolution graphics are created. There are 176 dots from
top to bottom of the screen, and 256 from left to right.
Each of these dots can be defined by a coordinate (like a
place can be fixed by a map coordinate). The dot at the
bottom left of the screen has the coordinate 0,0 and the
one at top right 255,175. If you move vertically up or down
the screen, you are moving along the y axis, and moving
horizontally left and right, you move along the x axis.
   All that may seem horribly mathematical, but I hope it
will be clearer when we use the SET instructions to move
the turtle. The instruction SETX will move the turtle along
the x-axis (horizontally left or right) to a specified
point. Thus, SETX 10 will move the turtle from whereever it
is on the screen horizontally to a point which is 11 dots
(remember the first has the number 0) from the left hand
edge of the screen. Similarly SETY 10 will move the turtle
vertically to a point 11 dots from the bottom edge of the
screen, not counting the command line. If you move the
turtle with the pen down, a line will be drawn. Try this
example. Reset the turtle with the DRAW instruction, then
enter the command:

SX 60 SY 140 SX 128 SY 88 (and press ENTER)

This will draw horizontal and vertical lines to create a
rectangle.
   The command SETXY will move the turtle to the coordi-
nates specified after the command. You'll need two numbers
after SETXY: the first is the x-coordinate, the second the
y-coordinate. For example, with the rectangle from the
above routine still on the screen, enter:

SETXY 60 140 (or XY 60 140) and press ENTER

This will draw a diagonal to the rectangle, taking the
turtle to the coordinates 60,140, which is one corner (the
top left corner) of the box.
   Try a number of SETX, SETY and SETXY instructions for
yourself. The X number must be between 0 and 255, and the
Y number between 0 and 175.

 Direction

You may have noticed that, in using these SET instructions,
that the turtle's direction (or heading) is not changed
from that before the SET instruction was used. There is an
additional instruction to alter the heading of the turtle
to a definite direction; this is the SETHEADING command.
Fig. 2-3 shows you the direction a turtle will take from
a given SETHEADING. SETHEADING 0 will direct the turtle to
point vertically up the screen; SETHEADING 270 will point
the turtle horizontally towards the left edge of the
screen. The heading you give to the turtle must be between
0 and 360.
   If you are confused between the SETHEADING and LEFT and
RIGHT commands, then remember, SETHEADING gives you /abso-
lute/ command of the heading whereas LEFT and RIGHT turn
the turtle /relative/ to the turtle's current direction.
   One final piece of theory for this part before we try a
few more examples. If you remember, {above} we created a
square with the instructions:

FD 40 RT 90 FD 40 RT 90 FD 40 RT 90 FD 40 RT 90

You have probably noticed that the two commands FD 40 RT 90
are repeated 4 times. There is a command in LOGO which
helps in repetition. Quite logically, that command is
REPEAT (RP for short). Here's how it is used in drawing a
box. Clear the screen with the DRAW command, then enter the
command:

RP 4 [ FD 40 RT 90 ] and press ENTER

The number after REPEAT (or RP) is the number of times the
commands within the square brackets are to be repeated.
Remember, always leave a single space between commands,
numbers, and square brackets. To be complete, the REPEAT
command /must/ be followed by a number, then an 'open'
square bracket. A 'close' square bracket indicates the end
of the repeated loop.

 Nested Loops

In the same way that FOR-NEXT loops can be 'nested' in
BASIC, so can REPEAT loops be nested. As an example, the
following LOGO instruction will produce the symmetrical
pattern in fig. 2-4.
   The two loops are shown by the lines drawn above the
instruction. Nesting of loops is easier in LOGO than in
BASIC, and as lont as you have the same number of "[" as
"]", then you shouldn't go too far wrong!

      +--------outer loop----------+
      |            +-inner loop--+ |
      |            |             | |
RP 12 [ RT 30 RP 8 [ RT 45 FD 20 ] ]
   |        |    |       |
   +-12 x 30+    +-8 x 45+
      =360         =360

The above command can be quite simply varied to produce a
variety of symmetrical shapes. If you look at the command,
I've linked together (under the command) two sets of two
numbers. If you multiply the first two together, you should
get 360, and if you multiply the second you'll also get
360. And that is the trick in getting symmetrical patterns.
You can replace any pair of numbers with another pair, so
long as the new numbers in the pair, when multiplied
together, produce 360. Why not try a few, and see what
shapes you can produce.
   Here are 3 other pattern drawing routines you may like
to try:

1. DRAW RT 20
   RP 5 [ FD 40 RT 135 FD 40 LT 63 ]

2. DRAW PU XY 80 60 PD
   RP 8 [ FD 40 RT 45 ] RT 45
   RP 8 [ FD 96 RT 135 ]

3. DRAW PC 1 RP 3 [ FD 40 RT 120 ]
   PC 2 RP 3 [ BK 40 LT 60 ]
   LT 90 PC 3 RP 3 [ FD 40 RT 120 ]
   PC 4 RP 3 [ BK 40 LT 60 ]

Type in one line at a time, pressing ENTER when you get to
the end. Try and follow what is happening on the screen, 
and relate it to the instruction you have just entered.
You'll find that you should soon understand most of the
LOGO commands I've introduced so far.


Figures for part 2:

{ Fig. 2-1 was the listing again. }


 Full command   Two letter
                abbreviation

 pencolour      pc
 wrap           wr
 nowrap         nw
 copy
 save
 stop
 setx           sx
 sety           sy
{setxy          xy - this was missing from the table}
 setheading     sh
 repeat         rp

Fig. 2-2. The new LOGO commands introduced in this {part}


       Top of screen
             A
    315      |      45
        \    |    /
          \  |  /
            \|/
 270 --------*-------- 90
            /|\
          /  |  \
        /    |    \
    225      |      135
            180
      Base of screen

Fig. 2-3. Angles to be used with the setheading command


{ Fig. 2-4 can't be done justice in ASCII art. I've added
  it to the Slogo parts.tzx file as "Fig. 4" SCREEN$. }


-----------------------------------------------------------


There are two additional commands {...}. The first is
BACKGROUND (BG), which allows you to define the paper
colour in specified areas of the screen. Five numbers are
required after BACKGROUND to complete the command. Here is
an example which you can try:

BACKGROUND 0 0 31 6 5

   The first four numbers define the area, a rectangle, to
be "painted", and the last number is the colour (0 to 7, as
shown on the Spectrum keyboard). The first two numbers are
the x and y coordinates of the top left point of the area
to be coloured. In the example, 0 0 refers to the top left
of the screen, unlike the coordinates for SET which start
at the bottom of the screen. In fact, the first two 
BACKGROUND coordinates are the same as the BASIC PRINT AT.
The third and fourth numbers of the BACKGROUND command are
the width and height of the square to be coloured. In the
example, the number 31 is the full screen width, and the
number 6 means six squares down. The number 5 is the colour
cyan, and so the example given will "paint" a cyan block at
the top of the screen. In an example later on, the same
command will create the sky in a scene which will be
created with LOGO commands.
   The other new command in this {part} is LIST. It will
list to screen or printer a LOGO protram. But as I haven't
yet explained how to create a LOGO program, you won't yet
have anything to list!

 Defining Logo Commands

LOGO programs are made by creating new commands from the
commands that LOGO already understands. You can create a
new command using DEFINE (DF). Most versions of LOGO use TO
instead of DEFINE, but I've used the latter as it is more
explanatory. You complete the DEFINE command with the new
command name, which must be different from all the commands
currently available to LOGO. As an example, let's tell the
computer how to draw a box: we'll define a command called
BOX. First enter the command:

DEFINE BOX (or DF BOX)

The screen will clear after the computer has checked that
the command BOX doesn't already exist. You'll get the
message 'Define box' at the top of the screen, and the
usual 'W:' at the base of the screen.
   There is no standard way of defining new commands in
LOGO; there are probably as many different ways as there
are versions of LOGO. So the instructions that follow just
happen to be the way I have decided to allow the definition
of new commands.
   To define our box, enter the command:

RP 4 [ FD 40 RT 90 ]

and press ENTER.

That line will appear at the top of the screen with a line
number of zero. The line number is not used by LOGO; I've
just added it to identify lines in case we want to make any
changes. In any one definition, you can enter up to 10
lines, but no line can be longer than 28 characters. For
out BOX definition, all we need is the one line already
entered, so we tell the computer we've finished by entering
END. You'll get a message to tell you that the new command
BOX has been stored, then you're back to a clean sheet of
paper, and the 'W:' symbol. The LOGO program will now
accept BOX as a command; try it!
   You can include in your definitions already defined
commands. As an example, define another command PATTERN,
as follows:

DEFINE PATTERN
RP 8 [ BOX RT 45 ]
END

   When complete, enter PATTERN as a direct command; you'll
get a pattern based on the BOX routine you defined. Fig. 
3-2. contains another command called MOVE, which also uses 
BOX. Define the command as before, then enter MOVE as a
direct command. This definition uses several commands which
were described in parts 1 and 2.

 Editing Commands

The pattern created PATTERN wasn't particularly exciting;
we could change PATTERN to improve it. To do this we use
the command EDIT. The syntax is EDIT PATTERN. Once you have
entered this command, the computer will spend a few moments
searching for PATTERN, then reformatting, ready for changes
to be made. The definition will reappear on the screen as
you entered it (apart from END). At the bottom of the
screen is a menu of editing options.
   * Option 1 is EDIT. It will allow you to change a line.
Enter the line number of the line you wish to change, and
re-enter the line as you want it.
   * Option 2, INSERT, allows you to insert another line
between two lines on the screen. Remember, you cannot
exceed a total of ten lines, so you can insert a line if
you have 9 lines or fewer in your definition. If you opt to
insert a line, say number two, then the previous line two
becomes number 3, 3 becomes 4, and so on.
   * DELETE (option 3) allows you to delete a line.
   * REMOVE (option 4) will remove the whole definition.
Pressing 5 will return you to normal command ('W:').
   So, to EDIT the command PATTERN, you will want to change
line zero. Press 1 to get the EDIT option, and press 0 to
indicate that it is line 0 which you want to replace. Then
enter:

RP 12 [ BOX RT 30 ]

   Press 5 to exit the edit routine, enter the direct
command DRAW to clear the screen and reset the turtle, then
try PATTERN again.

  LOGO Structures

By now you should already have an idea of how programs are
built up in LOGO. Each definition should be quite inde-
pendent; you shuld check it out before moving on to the
next definition. This is structured programming. It has the
advantage of being easier to follow what is happening
(than, for example, 'unstructured' BASIC), so it should be
easier to correct any mistakes. Programs written in this
way are also much easier for others to understand. The BBC
machine's PROCEDURE and the QL's DEF PRO also allow
programs to be structured in a similar way.
   To start you off in LOGO programming, fig. 3-3. contains
a listing, obtained by the LIST command. When entering a
LOGO program, remember to enter one definition at a time
(end each with END, which is not shown in the listing),
then test it and edit as necessary before moving on to the
next. In the example program, notice that the command SCENE
is the command which uses all the other commands in its
definition. It is the command which is central to the
operation of the program; you operate the whole program
(when it's all in the computer) by entering the direct
command SCENE. In this way LOGO differes from BASIC. Its
programs will not start with a single RUN command; they
start with a defined command which is the 'core' of the
program.
   There is more to LOGO than the aspects I have covered in
this series. LOGO also uses variables; it allows decision
making with IF ... THEN ... ELSE structures; and it permits
text handling. If you want to know more about LOGO, there
are several good books available (for example, LOGO Pro-
gramming by Peter Ross). Despite the limitations of my
program, I hope you have gained an insight into the fas-
cinating possibilities that LOGO is able to offer as an
introduction to programming to young and old, or simply, as
an easy to use graphics creation package.


Figures for part 3:

{ Fig. 3-1 was the listing. }


 define move
 pu xy 50 {50} pd box
{The y coordinate was missing from the previous line - 
 the listing in the article wouldn't have worked.}
 pu sx 120 pd box
 pu sx 190 pd box
 end

Fig. 3-2. Definition of the command MOVE


Fig. 3-3. An example LOGO program
 Definition - sky

 0  bg 0 0 31 5 5

 Definition - sun

 0  pu xy 40 160 pc 6 pd
 1  sx 42 pu xy 38 159 pd
 2  sx 44 pu xy 37 158 pd
 3  sx 45 pu xy 37 157 pd
 4  sx 45 pu xy 38 156 pd
 5  sx 44 pu xy 40 155 pd
 6  sx 42 pu

 Definition - ground

 0  bg 0 6 31 14 4

 Definition - house

 0  bg 20 10 5 5 2
 
 Definition - door

 0  bg 22 13 1 2 1

 Definition - windows

 0  bg 21 11 0 0 7
 1  bg 24 11 0 0 7

 Definition - roof

 0  pu xy 160
 1  96 pc 0
 2  pd sh 45 fd 33 rt 90 fd 33

 Definition - scene

 0  sky sun
 1  ground tree
 2  house roof door windows
 3  pu xy 200 160 sh 180
 4  pd

 Definition - tree

 0  pu xy 80 100 pc 0 pd
 1  sh 90 rp 8 [ fd 7 lt 45 ]
 2  fd 2
 3  rt 90 fd 30 lt 90 fd 1
 4  lt 90 fd 30 rt 90 fd 1
 5  rt 90 fd 30


-----------------------------------------------------------


{ That is the end of the text of the original series. What
  follows are a few remarks of my own.
    First, yes, it's slow. It's exceptionally slow. Set
  your emulators to warp speed 9. Anyone running this on a
  real Speccy must have had phenomenal patience. But it
  works!
    Second, there is one limitation that was not mentioned
  in the article text (and may not even have been noticed
  by the author). There is a limit of 200 characters per
  definition, total, including spaces _and newlines_. This
  means that if you cram each line of a definition full of
  commands, the program crashes. Beware, and save your work
  before and after editing a particularly large definition.
    Third, about the TZX files. As I alluded to above, the
  "Slogo parts.tzx" file contains the separate code of the
  individual parts, and a screen shot of figure 4 from
  part 2. 16k experimenters will find that "part 1" from
  this TZX is the only program which will work for them.
  "Slogo.tzx" contains the completed program, plus two
  sample LOGO programs. Both of these were entered normally
  in Slogo and saved from within the program. The first is
  "scene", and contains the sample program from part 3. Run
  it by loading the program and then entering "draw scene".
  The second sample is of my own devising, and is called
  "Turtles". Omnians may find it interesting to load it,
  then "draw Turtle1" and "draw Turtle2". Note the modal
  way in which the text is drawn: a simple example of how
  to write structured programs in Logo.
    Finally, I leave you with something you may find useful
  if you want to experiment with Slogo: a complete table of
  all built-in Slogo commands from all three parts, with a
  short description of their functions.


 home             
   Move turtle to the centre of the screen, pointing at the
   top of the screen.
 draw
   Clear screen, then go home.
 wrap          wr
   Allow turtle to wrap over the screen edges (default).
 nowrap        nw
   Disallow turtle from wrapping over the screen edges.

 forward       fd   l
   Move forward l pixels, drawing if the pen is down.
 back          bk   l
   Turn 180 degrees, then move (or draw) l pixels.
 left          lt   d
   Turn the turtle left through d degrees.
 right         rt   d
   Turn the turtle right through d degrees.

 setx          sx   x
   Move the turtle horizontally to an absolute x coordi-
   nate, drawing if the pen is down.
 sety          sy   y
   Move (and draw) vertically to an absolute y coordinate.
 setxy         xy   x y
   Move (and draw) to an absolute x,y pixel position.
 setheading    sh   d
   Turn the turtle to an absolute heading of d degrees
   right from pointing to the top of the screen.

 penup         pu
   Lift the 'pen' from the 'paper', so movement commands do
   not draw.
 pendown       pd
   Lower the 'pen' to the 'paper', so movement commands do
   draw.
 pencolour     pc   cl
   Cause all drawing commands draw in Spectrum colour cl.
 background    bg   c r w h cl
   Paint character blocks (not pixels) from column c and
   row r, width w+1, height h+1 blocks, with paper colour
   cl, leaving drawn contents intact.
  
 repeat        rp   n [ <commands> ]
   Execute the <commands> between the square brackets
   n times.

 define        df   name
   Define a new Logo command with the given name, which may
   not already be a known command.
 edit          ed   name
   Edit the command with that name, which must have been
   previously defined and must not be a built-in command.
 list          li
   List all user-defined commands on screen or printer.

 copy
   Copy the screen to an attached printer.
 save
   Save the program to tape, complete with the current
   user-defined commands.
 stop
   Halt the program and return to Basic.

 random             n
   The only available function; returns a whole number
   between 0 and n-1.
}