Sharp OZ-707 Operation Manual - Page 24
An n-dimensional array is declared by the statement - 320
UPC - 074000012141
View all Sharp OZ-707 manuals
Add to My Manuals
Save this manual to your list of manuals |
Page 24 highlights
The first statement creates an array X with 6 storage locations. The second statement creates an array AA with 25 locations. The third statement creates an array with one location and is actually illogical since (for numbers at least) it is the same as declaring a single-value numeric variable. It is important to know that an array-variable X and a variable X are separate and distinct to the Card. The former denotes a series of numeric storage locations, and the latter denotes a single and different location. Now that you know how to create arrays, you might be wondering how we refer to each storage location. Since the entire group has only one name, the way in which we refer to a single location (called an "element") is to follow the group name with a number in parentheses. This number is called a "subscript". For example, to store the number 8 in the fifth element of our array X (declared previously) we would write: X(4) = 8 If the use of 4 is puzzling, remember that the numbering of elements begins at zero and continues through to the number of elements declared in the DIM statement. The real power of arrays lies in the ability to use an expression or a variable name as a subscript. An n-dimensional array is declared by the statement: DIM array-variable-name (size 1, size 2, ..., size n) where: size n specifies the number of elements in the nth dimension of the array. Note that when you specify the number of elements, you get one more element than indicated by the specification. The following diagram illustrates the storage locations that result from the declaration DIM T(2, 3) and the subscripts (now composed of two numbers) that pertain to each location: 36 row 0 row 1 row 2 column 0 T (0,0) T (1, 0) T (2, 0) column 1 T (0, 1) T (1, 1) T (2, 1) column 2 T (0, 2) T (1, 2) T (2, 2) column 3 T (0, 3) T (1 , 3) T (2, 3) Note: Two-dimensional arrays can rapidly use up storage space. For example, an array with 25 rows and 35 columns uses 875 storage locations! An n-dimensional array has n indices into the array. For example, DIM Z$(3,3,3,4) generates a 4-dimensional array with 320 elements. The following table shows the number of bytes used to define each variable and the number used by each program statement. Variable type Single-precision numeric variable Double-precision numeric variable String (array) variable Number of bytes used Variable name Data (Length of variable name + 4) bytes 7 bytes (Length of variable name + 4) bytes 12 bytes (Length of variable name + 8) bytes The number of stored string (array) data (bytes) Element Number of bytes used Line number 3 bytes Statement & function 2 bytes I ENTER I 1 byte Double-Precision Variables Existing single-precision variables can be converted to double-precision variables by appending a sharp mark (#). For example: A#, AB#, X#(10), Y#(2,3) and X1#(5,6). 37