Dim - AMSTRAD cpc 6128 User Instruction

Integrated computer/disc system
Hide thumbs Also See for cpc 6128:
Table of Contents

Advertisement

DIM
D I M <list of: < sub scripted variable>
10 C
LS
20 DIM friend$(5),phone$(5)
30 FOR n=1 TO 5
40 PRINT "Friend number";n
50 INPUT "Enter name";friend$(n)
60 INPUT "Enter teL.number";phone$(n)
70 PRINT
80 NEXT
90 FOR n=1 TO
J
100 PRINT n;friend$(n),phone$(n)
110 NEXT
run
COMMANDi DIMensions an array. D I M allocates space for arrays and specifies
maximum subscript values. BASIC must be advised of the space to be reserved for an
array, or it will default to 10.
An array is identified by a <subscripted variable> where one variable name is used
with a range of subscript numbers,
S0
that each 'element' of the array has its own
individual value. Control of the array can then be achieved by for example FOR
NE X T loops, which can step through the array, processing each element in turn.
Note that the lowest value of the subscript is zero (Le. the first available element in
the array).
Arrays can be multi-dimensional, and each element of such an array is referenced by
its position within the framework of the array. For example, in an array dimensioned
by:
DIM position$(20,20,20)
.... an element of the array would be referenced for example:
position$(4,5,6)
Associated keywords: ERA S E
Chapter 3 Page 18
Complete List of Keywords

Advertisement

Table of Contents
loading

Table of Contents

Save PDF