Locate - AMSTRAD CPC464 User Manual

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

Advertisement

4.9 LOCATE

So far, most BASIC commands have been written using the universal BASIC syntax that can be
understood by most machines that include any sort of BASIC interpreter. LOCATE is one of the
dialect features of AMSTRAD BASIC (and several others) that allows you to position the text cursor
anywhere on the screen:
L O C A T E 1 O , 4
. ..places the text cursor in the 10th column, 4 lines down from the top of the screen.
If you attempt to do this as a direct statement, the cursor will LOCATE - but the Ready prompt will
cause a new line to be started so that the cursor ends up on the left margin once again. Add line 16:
1 6 L O C A T E 1 O , 4
run
and see that the first input request is lowered and inset accordingly. The next line carries on as
before - flush left - since line 25 inserts a couple of empty lines. Press [ESC] twice, then add line 26:
2 6 L O C A T E 10,4
RUN the program, and the second question ' overwrites' the first. You can now carry on placing the
text exactly where you want it to appear on the screen, using the co-ordinates on the screen planners
listed in Appendix 6.
If you want all the questions and comments to appear on the same line, then you should precede
each LOCATE by a C L S : to avoid confusion with the remains of the last entry.
Note that the co-ordinates of LOCATE may be variables themselves, generated from within,the
program. We' ve worn the ' salary' program out by now, so the next example will be based on a
different topic. If you want to save what you have constructed this far, then do so now using the
cassette commands of Chapter 2. You may even have grown to like the program by now - so you may
wish to keep it to refer to, and expand it further with the commands about to be introduced.
4.10 IF....THEN
Its use is straightforward and quite literal. IF logical expression, T H E N G O T O line number is one
of several forms of the command.
IF checks to see if the result of the logical expression happens to be true – in which case the option
is executed. The IF operation can be built into loops that
repeat when a specified condition is, or is not satisfied. Beset the computer using
[CTRL][SHIFT][ESC] and type in:
1 MODE 1
1 0 A M S T R A D = 0
2 0 P R I N T " A M S T R A D C P C 4 6 4 c o l o u r p e r s o n a l
c o m p u t e r "
3 0 A M S T R A D = A M S T R A D + 1
4 0 I F A M S T R A D < 1 0 G O T O 2 0

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents