100 CLS
190 INPUT "Whose number do you want",name$
200 search=0
210 REPEAT
220 search=search+1
230 IF name$=friend$(search) THEN PRINTname$;" has the number
" ;numb$(search)
240 UNTIL search=count OR name$=friend$(search)
250 IF name$<>friend$(search) THEN PRINT'"I can't find this name"
260 ENDPROC
PROCread _file reads the contents of the file back into memory and stores the
names and phone numbers in two arrays friend$( ) and numb$( ).
Line 90 opens the file using OPENIN so that data can be input from it. Once
again we save the channel number, this time storing it in the variable
that _one.
The loop from lines 110 to 140 reads in items from the file and stores the data in
the arrays. Line 130 inputs data via the channel that _ one.
The computer does not know how many data items there are in the file, so it
continues to read data until it reaches the End Of File (EOF) at line 140. As
there is no more data, line 150 closes the file.
Al] the data has now been copied from the file into the arrays friend$( ) and
numb$( ), and PROCfind _number searches those arrays for the phone
number if you input as friend's name.
The previous two programs are very simple and only illustrate the principles of
using files. Much more sophisticated software is available which allows you to
create and modify files of data of any nature, rather than specifically names
and phone numbers. You can expand your system to include ViewStore, a very
powerful file-handling program, details of which are available from Acorn.
More about graphics
In any graphics mode a fixed number of pure colours can be shown on the
screen simultaneously. Four other patterns made up from a combination of the
pure colours can also be displayed. For example, in mode 129 four pure colours
are available, and four patterns. This program displays all eight colours at the
same time by drawing seven rectangles on a background of black:
10 MODE 129
20 PR0Cpure
30 PROCmixed
40 END
50 DEFPR0Cpure
C56