The Structure Of A Basic Program; Line Input; Terminology - AMSTRAD CPC464 User Manual

Cpc464 colour personal computer 64k
Hide thumbs Also See for CPC464:
Table of Contents

Advertisement

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:
f o r n = 1 t o 5 0 : ? n : n e x t
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.

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents