170 IF LEFT$(name$,1)=letter$ THEN PRINT name$

180 NEXT count

190 ENDPROC

This program contains only a few names, but the computer can deal just as

easily with a list of several hundred names -- the limiting factor is the

computer's memory capacity.

It is more common to deal not with a single array but with several

simultaneously. We usually make lists of data items that are in some way

associated -- names and addresses, books and their authors, and so on. For

example, if names and ages are being stored we can set up two arrays. The

association between the arrays makes it easy for the computer to carry out

searches. If Broome is the fifth name in the names array, his or her age is fifth

in the age array:

name$(5)="Broome" age(5)=27

Here the age is stored in a numeric array age( ) rather than a string array,

because we may want to carry out a calculation involving the age.

This program stores the names and ages of 10 people, and searches the array to

find the age of any person once you have input their surname:

10 MODE 135

20 PR0Cset_up_array

30 PR0Cfind_age

40 END

50 DEFPROCset_up_array

60 DIM name$(10), age(10)

70 FOR count=1 TO 10

80 READ name$(count), agetcount)

90 NEXT count

100 ENDPROC

110 DATA Smith,42,BLoggs,35,Hutchings,57

120 DATA Postlethwaite,35 ,Broome,49,Turner,23

130 DATA Dick,39,James,24 ,Neale,63,Sewell,75

140 DEFPR0Cfind_age

150 INPUT "Whose age do you want ",search$

160 count=l

170 REPEAT

180 name$=name$(count)

190 IF name$=search$ THEN PRINT name$;" is ";age(count)

200 count=count+l

210UNTIL count=11 OR name$=search$

220 IF name$<>search$ THEN PRINT search$;" is not in the list"

230 ENDPROC

C53