Sinclair QL Beginner's Manual page 29

Hide thumbs Also See for QL:
Table of Contents

Advertisement

CHAPTER 5 - KNOWN GOOD PRACTlCE
You have already begun to work effectively with short programs. You may have found the following
practices are helpful:
1.
Use of lower case for identifiers: names of variables ( pigeon holes ) or repeat structures, etc.
2.
Indenting of statements to show the content of a repeat structure.
3.
Well chosen identifiers reflecting what a variable or repeat structure is used for.
4.
Editing a program by:
replacing a line
inserting a line
deleting a line
PROGRAMS AS EXAMPLES
You have reached the stage where it is helpful to be able to study programs to learn from them and to
try to understand what they do. The mechanics of actually running them should now be well
understood and in the following chapters we will dispense with the constant repetition of:
NEW before each program
 at the end of each line
RUN to start each program
You will understand that you should use all these features when you wish to enter and run a
program. But their omission in the text will enable you to see the other details more clearly as you try
to imagine what the program will do when it runs.
If we dispense with the above details we may use and understand programs more easily without the
technical clutter. For example, the following program generates random upper case letters until a Z
appears. It does not show the words NEW or RUN or the ENTER symbol but you still need
to use these.
10 REPeat letters
20 LET lettercode = RND(65 TO 90)
30 cap$ = CHR$(lettercode)
40 PRINT cap$
50 IF cap$ = "Z" THEN EXIT letters
60 END REPeat letters
In this and subsequent chapters programs will be shown without ENTER symbols. Direct commands
will also be shown without ENTER symbols. But you must use these keys as usual. You must also
remember to use NEW and RUN as necessary
AUTOMATIC LINE NUMBERING
It is tedious to enter line numbers manually. Instead you can type:
AUTO
before you start programming and the QL will reply with a line number:
100
Continue typing lines until you have finished your program when the screen will show:
100 PRINT "First"
110 PRINT "Second"
120 PRINT "End"

Advertisement

Table of Contents
loading

Table of Contents