3.2 The structure of a BASIC program
Program instructions are presented to BASIC on lines. A line may comprise several commands,
separated by colons, limited only by the maximum line length of 255 characters. A ‘character’ is a
number, letter, space. In Direct Mode lines are typed in from the keyboard and must not commence
with a number. In Program Mode lines are read from the current program in memory, and are
executed in strict sequence according to the number that appears as the first entry on the line.
AMSTBAD BASIC allows the user to add and remove lines from the program whilst in direct mode,
and to amend existing lines. Before RUNning or LISTing a program, BASIC will internally re-
organise the order of the lines in ascending numerical sequence, regardless of the order in which
they were entered.
3.3 Line Input.
BASIC accepts lines of up to 255 characters, terminated by [ENTER]. During line input, it is possible
to edt the current line, and to use the COPY cursor facilities to insert characters from elsewhere on
the visible screen display - see chapter one section 1.2.7.
All keywords must be delimited by a separator - which is either a space, mathematical operator (+ -
etc.) or other recognised character. This is because it is permissable to use variables where a
keyword (or reserved word) forms part of the variable - obviously a reserved word cannot be a
variable unless ‘surrounded to prevent the computer from recognising the start and end of the
instruction.
Keywords may be entered either as lower case letters (un[SHIFT]ed), or CAPITAL letters
([SHIFT]ed).
The command PRINT may be abbreviated to a question mark ? and when used in this form, the
delimiter is not required. Mathematical operators (+-* / MOD \) also perform the function of
delimiting the keyword, so the following is valid, although not encouraged, since it may encourage
bad habits in program entry where spaces are necessary:
for n=1 to 50:?n:next
Similarly, a single quote mark ’
([SHIFT]
7) can be used as a substitute for : R EM in remark
statements.
Additional spaces will be ignored, and may used to ‘format’ the program listing to indicate areas of
loops etc.
3.4 Terminology
In order to describe BASIC commands and keywords, a formal but simple terminology must be used.
Each command is described as it should appear when entered at the keyboard, with any variable or
optional parts shown by various types of brackets or parentheses which refer to items detailed in’ the
subsequent description.
Содержание CPC464
Страница 1: ......
Страница 32: ...or you can type 3e1 1e1 ENTER 300 2 3000x1000 Type 3e3 1e3 ENTER 3000000 3 3000x0 001 Type 3e3 1e 3 ENTER 3 ...
Страница 102: ...PRINT 10 AND 12 Results in 8 PRINT 10 AND 1000 Results in 8 again ...
Страница 118: ...TO DO DRAW THIS PAGE ...
Страница 219: ...actual value may be made to vary during the execution of a program ...
Страница 240: ...Text and WINDOW planner Mode 2 80 Columns ...
Страница 241: ......
Страница 245: ...Sound envelope Music planner sheet ...