EasyManua.ls Logo

AMSTRAD CPC464 - Page 99

AMSTRAD CPC464
249 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
An example program is:
10 READ X,Y,Z
20 PRINT X;"+";Y;"+";Z;" = ";X+Y+Z
30 DATA 1,3,5
The data can be either numerical or text or a mixture of both. Dont worry if all your data doesnt fit
onto one line you just start a new line with the DATA command at the beginning. When the
computer comes across a READ command it searches through the program for the next sequential
piece of data regardless of where it may occur. Make sure you have sufficient data for all your
READs or an error will result.
The only way to interrupt this sequential input of data is to use the RESTORE command. This sets
the data pointer to the beginning of the program again allowing the same data to be read several
times if required. This program illustrates the use of the DATA,READ and RESTORE commands:
10 FOR C =1 TO 5
20 READ X$
30 PRINT X$;" ";
40 NEXT C
50 RESTORE
60 GOTO 10
70 DATA HELLO,HOW,ARE,YOU,TODAY
Press [ESC] to break from this program.
Note that although the data line has been placed at the end of the program in the example, it can be
located anywhere that is convenient.
The DATA command need not be used just to contain information which is to be PRINTed when
read; numeric values in a DATA statement can, for example, be read into a SOUND command. Type
in:
10 FOR n=1 TO 30
20 READ s
30 SOUND 1,s,40,5
40 NEXT n
50 DATA 100,90,100,110,120,110,100,0
60 DATA 130,120,110,0,120,110,100,0
70 DATA 100,90,100,110,120,110,100,0
80 DATA 130,0,100,0,120,150
If you cannot hear anything, adjust the volume control at the right hand end of the computer.
Concluding this brief introduction to BASIC, heres a program that enables you to play pontoon with
the CPC464 (blackjack and 21 are the other well known names for variations). It demonstrates the
use of many features of BASIC, and should be readily understood thanks to the use of renresentative
variable names. You can embellish it with graphics, add tension with sound - and generally develop
the theme in the way that all the best BASIC programs evolve from a humble core.
The object of the game is get as close to a total of 21 by adding the face values of the cards in your
hand, and then for the house to attempt to match this, or get closer still - without exceeding 21 and
so going bust. After typing in line 1, use the command AUTO to automatically generate the line
numbers..
1 REM PONTOON
10 REM INITIALISE
20 YC=2:CC=2
30 ACES=0
40 CACES=0
50 S=0
60 T=0
70 DIM SUIT$(4)

Table of Contents

Other manuals for AMSTRAD CPC464

Related product manuals