Variables, Operators And Data; Spot The Reserved Word - AMSTRAD CPC464 User Manual

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

Advertisement

4 Variables, operators and
data
Handling the information in a BASIC program
Subjects covered in this chapter:
* Getting familiar
* Variable types
real, integer and string
:
* Operators, logical expressions
* Arrays
* DATA

4.1 Spot the reserved word

Note (if you haven' t already) that the commands and other reserved words in AMSTRAD BASIC are
delimited, either by spaces or punctuation marks, numeric operators etc. Programs are easier to read
and debug, because although you may enter the keywords either in UPPER CASE or lower case -
when the program is LIST ed, all keywords have been converted to UPPER CASE anyway. If they
haven' t then there is an error concerning the way they have been typed in, and the program will not
run.
AMSTRAD BASIC allows you to imbed keywords into variable names. A variable in AMSTRAD
BASIC is a name that you assign to a specific element. It can be as simple as a single letter
(variables must always start with a letter - not a number), although its easier to read and
understand a long program if you use variable names that reflect what' s going on:
A N S W E R = 4 * 4 : p r i n t A N S W E R
Variables in AMSTRAD BASIC may contain up to 40 characters (the first must be a letter), and all
40 are significant. Variables must not contain any spaces - or BASIC will only read the letters (or
letters and numbers) up to the first space and then respond with:
S y n t a x e r r o r
Which is indicating that an illegal sequence of characters has been entered (see Appendix VIII). If
you want to include phrases with words separated, then use a full stop . where you would otherwise
have left a space. All the usual forms of subscripted variables are possible, bearing in mind the need
to DIM ension arrays.

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents