Sinclair QL Beginner's Manual page 58

Hide thumbs Also See for QL:
Table of Contents

Advertisement

CHAPTER 9 - DATA TYPES VARIABLES AND IDENTIFIERS
You will have noticed that a program (a sequence of statements) usually gets some data to work on
(input) and produces some kind of results (output). You will also have understood that there are
internal arrangements for storing this data. In order to avoid unnecessary technical explanations we
have suggested that you imagine pigeon holes and that you choose meaningful names for the pigeon
holes. For example, if it is necessary to store a number which represents the score from simulated
dice-throws you imagine a pigeon hole named score which might contain a number such as 8.
Internally the pigeon holes are numbered and the system maintains a dictionary which connects
particular names with particular numbered pigeon holes. We say that the name, score, points to its
particular pigeon-hole (by means of the internal dictionary).
The whole arrangement is called a variable.
What you see is the word score. We say that this word, score is an identifier It is what we see and it
identifies the concept we need, in this case the result, 8, of throwing a pair of dice. Because the
identifier is what we see it becomes the thing we talk or write or think about. We write about score and
its value at any particular moment.
There are four simple data types called floating point, integer string and logical and these are
explained below We talk about data types rather than variable types because data can occur on its
own, for example 3.4 or 'Blue hat' as the value of a variable. But if you understand the different types
of variables, you must also understand the different types of data.
IDENTIFIERS AND VARIABLES
1. A SuperBASIC identifier must begin with a letter and is a sequence of:
upper or lower case letters
digits or underscore
2. An identifier may be up to 255 characters in length so there is no effective limit in practice.
3. An identifier cannot be the same as a keyword of SuperBASIC.
4. An integer variable name is an identifier with % on the end.
5. A string variable name is an identifier with $ on the end.
6. No other identifiers must use the symbols % and $.
7. An identifier should usually be chosen so that it means something to a human reader but for
SuperBASIC it does not have any particular meaning other than that it identifies certain things.
FLOATING POINT VARIABLES
Examples of the use of floating point variables are:
100 LET days = 24
110 LET sales = 3649.84
120 LET sales_per_day = sales/days
130 PRINT sales_per_day

Advertisement

Table of Contents
loading

Table of Contents