BASIC PROGRAMMING
SECTION 4,9
A string array can be sized as follows:
10 IF Z<>O THEN 100
20 N=2
30 Y=INT (((FRE(0)-7-N*7-256)/15)-1)
40 DIM A$(Y
,4)
100 PRINT "TOTAL NUMBER OF STRINGS AVAILABLE:",Y
4,9,2,5
Accessing Array Elements
Each element in a data array is accessible by its array index,
expressed in parentheses, e.g:
A$(235)
is the 236th element in A$
NOTE: Array indexes must be within the range declared in the
corresponding DIM statement. HUNTER Basic warns the programmer
of any attempt to access an element outside the declared range
with:
*MAG Error
Be especially careful with incrementing indexes like FOR NEXT
loops.
Array indexes often have a direct relationship to external
variables, like stock codes. It is always preferable to
directly access an array in this fashion in the interests of
speed, rather than working sequentially through every element.
If there are discontinuities (gaps) in the existing codes, or if
the numbers are too large, a conversion table or algorithm may
be needed, Since a literal table (one entry for every code) is
likely to be very inefficient, it is generally worth putting
considerable effort into deriving an efficient 'tree' structure
for direct array access.
4,9,2.6
Array Searches
VER.V09F
There is often a need to search an array for an element of known
content. In Basic, this procedure can be painfully slow.
One solution to this dilemma is to use a specialised machine-
code subroutine to search the array and return with the index of
the target element.
PAGE 4 - 28