Sinclair QL Beginner's Manual page 46

Hide thumbs Also See for QL:
Table of Contents

Advertisement

CHAPTER 8 – FROM BASIC TO SUPERBASIC
If you are familiar with one of the earlier versions of BASIC you may find it possible to omit the first
seven chapters and use this chapter instead as a bridge between what you know already and the
remaining chapters. If you do this and still find areas of difficulty. it may be helpful to backtrack a little
into some of the earlier chapters.
If you have worked through the earlier chapters this one should be easy reading. You may find that,
as well as introducing some new ideas, it gives an interesting slant on the way BASIC is developing.
Apart from its program structuring facilities SuperBASIC also pushes forward the frontiers of good
screen presentation, editing, operating facilities and graphics. In short it is a combination of user-
friendliness and computing power which has not existed before.
So, when you make the transition from BASIC to SuperBASIC you are moving not only to a more
powerful, more helpful language, you are also moving into a remarkably advanced computing
environment.
We will now discuss some of the main features of SuperBASIC and some of the features which
distinguish it from other BASICs.
ALPHABETIC COMPARISONS
The usual simple arithmetic comparisons are possible. You can write:
LET pet1$ = "CAT"
LET pet2$ = "DOG"
IF pet1$ < pet2$ THEN PRINT "Meow"
The output will be Meow because in this context the symbol < means:
earlier (nearer to A in the alphabet)
SuperBASIC makes comparisons sensible. For example you would expect:
'cat' to come before 'DOG'
and
'ERD98L' to come before 'ERD746L'
A simplistic approach, blindly using internal character coding, would give the 'wrong' result in both the
above cases but try the following program which finds the 'earliest' of two character strings.
100 INPUT item1$, item2$
110 IF item1$ < item2$ THEN PRINT item1$
120 IF item1$ = item2$ THEN PRINT "Equal"
130 IF item1$ > item2$ THEN PRINT item2$
INPUT
cat
dog
cat
DOG
ERD98L
ERD746L
ABC
abc
The Concept Reference Guide section will give full details about the way comparisons of strings are
made in SuperBASIC.
VARIABLES AND NAMES - IDENTIFIERS
OUTPUT
cat
cat
ERD98L
ABC

Advertisement

Table of Contents
loading

Table of Contents