Sharp OZ-707 Operation Manual - Page 68

Abbreviation, Example

Page 68 highlights

DIM p o FORMAT: DIM variable name 1 (size 1[, size 2, size 3, ...J ) [, variable name 2 (size 1 [, size 2, size 3, ...J)] Abbreviation: D. See Also: ERASE, CLEAR, RUN PURPOSE: Reserves space for numeric and string array variables. REMARKS: DIM must be used to reserve space for an array variable. The size of an array is the number of elements in that array. A variable name consists of a letter and up to 39 alphanumeric characters. For string variables, "$" is attached to the end of the variable name. Numeric variables may be either single-precision or double-precision variables. Even though two variables may have the same name (one single-, one double-precision), they will be recognized as two different variables. Size 1, size 2 are called the "subscripts·, and specify the number of elements in the nth dimension of the array. An array with one subscript is called a one-dimensional array, with two subscripts, it is called a two-dimensional array and an array with n subscripts is called an n-dimensional array. Example: DIM B(3): one-dimensional array B( ) reserves 4 array elements B(O), B(l), B(2) and B(3) DIM XA$(2,3): two-dimensional string array XA$( ) reserves 12 array elements XA$(O,O), XA$(0,1), ..., XA$(2,2), XA$(2,3) Integers SS34 can be used as subscripts, but an error may occur if a variable with the specified size cannot be reserved because of limits in the memory size and conditions of use. 124 If the subscripts include a decimal point, only the integer part will be recognized (and the fractional part will be ignored). Example: X(2.3) recognized as X(2) Y(0.2S) recognized as Y(O) The subscript may be declared by a numeric variable or expression: 10: INPUT A,B 20: DIM X(A), Y#(B-1,A*B) More than one array can be declared using one DIM statement. Example: DIM V(S), K$(4,3), XB$(S) If an array has been defined, it cannot be defined again. For example, both DIM X(S) and DIM X(3,4) cannot be defined since the variable names are the same. However, DIM X!(S) and DIM X#(3,4) can be defined since one is a single-precision variable and the other is a double-precision variable. When a program is executed using the RUN or ARUN command, allocated array variables are cleared, but they are not cleared using the GOTO statement. Thus, when a program is to be executed again using the GOTO statement, an error will occur if a DIM statement attempts to reallocate space for an existing array variable. Either GOTO a line following the DIM statement, or add an ERASE statement and redefine the array. Example: SO: ERASE X: DIM X(3,4) Numerical array and string array variables are recognized as different arrays; thus, the arrays Z( ) and Z$( ) can be defined Simultaneously. The DIM statement cannot be used within a FOR...NEXT loop. 12S

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128

DIM
FORMAT:
DIM variable name 1 (size 1
[,
size 2, size 3, ...
J )
[,
variable name 2 (size 1
[,
size 2, size 3, ...
J)]
Abbreviation:
D.
See
Also:
ERASE, CLEAR, RUN
PURPOSE:
Reserves space for numeric and string array variables.
REMARKS:
DIM must be used
to
reserve space for an array variable.
The
size of
an
array
is
the
number
of
elements in that array.
p
o
A variable name consists of a letter and up to 39 alphanumeric
characters. For string variables, "$" is attached to the end
of
the
variable name. Numeric variables
may
be either single-precision
or
double-precision variables. Even though
two
variables
may
have the
same
name (one single-, one double-precision), they will
be
recognized
as
two
different variables.
Size 1, size 2 are called the "subscripts·, and specify the
number
of
elements in the nth dimension of the array. An array with
one
subscript
is called a one-dimensional array, with
two
subscripts, it is called a
two-dimensional array and an array with n subscripts
is
called an
n-dimensional array.
Example:
DIM B(3):
one-dimensional array B(
) reserves 4 array elements
B(O),
B(l),
B(2) and B(3)
DIM XA$(2,3):
two-dimensional string array XA$(
) reserves 12 array elements
XA$(O,O), XA$(0,1), ... , XA$(2,2), XA$(2,3)
Integers
<H>SS34
can
be
used as subscripts, but an error
may
occur if
a variable with the specified size cannot
be
reserved because
of
limits
in the memory size
and
conditions of use.
124
If the subscripts include a
decimal
point, only
the
integer part will
be
recognized (and the fractional part will be ignored).
Example:
X(2.3) recognized as X(2)
Y(0.2S) recognized as
Y(O)
The subscript may be declared
by
a numeric variable
or
expression:
10:
INPUT
A,B
20: DIM X(A), Y#(B-1,A*B)
More than
one
array can
be
declared using one DIM statement.
Example:
DIM V(S), K$(4,3), XB$(S)
If an array has been defined,
it
cannot be defined again. For example,
both DIM X(S) and DIM X(3,4) cannot be defined since the variable
names are the same. However, DIM X!(S) and DIM X#(3,4) can be
defined since one is a single-precision variable and the other is a
double-precision variable.
When a program is executed using the RUN
or
ARUN command,
allocated array variables are cleared, but they are not cleared using the
GOTO statement. Thus, when a program is to
be
executed again using
the
GOTO
statement, an error will occur if a DIM statement attempts to
reallocate space for an existing array variable. Either GOTO a line
following the DIM statement,
or
add an ERASE statement and redefine
the array.
Example:
SO:
ERASE
X: DIM X(3,4)
Numerical array and string array variables are recognized
as
different
arrays; thus, the arrays Z(
) and Z$(
) can
be
defined Simultaneously.
The DIM statement cannot be used within a FOR.
..
NEXT
loop.
12S