The part of the screen in which you have drawn lines and create other output is called a window.
Later you will see how you can change the size and position of a window or create other windows. For
the present we shall be content to draw a border round the current window. The smallest area of light
or colour you can plot on the screen is called a pixel. In mode 8, called low resolution mode, there are
256 possible pixel positions across the screen and 256 down. In mode 4, called high resolution mode,
there are 512 pixels across the screen and 256 down. Thus the size of a pixel depends on the mode.
You can make a border round the inside edge of a window by typing for example:
BORDER 4,2
This will create a border 4 pixels wide in colour red (code 2). The effective size of the window is
reduced by the border. This means that any subsequent printing or graphics will automatically fit
within the new window size. The only exception to this is a further border which will overwrite the
existing one.
A SIMPLE LOOP
Computers can do things very quickly but it would not be possible to exploit this great power if every
action had to be written as an instruction. A building foreman has a similar problem. If he wants a
workman to lay a hundred paving stones that is roughly what he says. He does not give a hundred
separate instructions.
A traditional way of achieving looping or repetition in BASIC is to use a GO TO (or GOTO, they are
the same) statement as follows.
NEW
10 PAPER 6 : CLS
20 BORDER 1,2
30 INK RND(5)
40 LINE 50,60 TO RND(100),RND(100)
50 GOTO 30
RUN
You may prefer not to type in this program because SuperBASIC allows a better way of doing
repetition. Note certain things about each line.
You can re-write the above program by omitting the GOTO statement and, instead, putting REPeat
and END REPeat around the part to be repeated.
NEW
10 PAPER 6 : CLS
20 BORDER 1,2
30 REPEAT star
40 INK RND(5)
50 LINE 50,60 TO RND(100),RND(100)
60 END REPEAT star
RUN
We have given the repeat structure a name, star. The structure consists of the two lines: