EasyManua.ls Logo

Husky Hunter - Page 144

Husky Hunter
499 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
BASIC PROGRAMMING SECTION 4.9
The variable Z is a flag, indicating that the program has been
run before. (All variables are cleared to Oby CLEAR or any
change to program content, but not by power off or removing
batteries) .
A slightly more sophisticated version is:
10 IF Z<>O THEN 100
20 DIM A$(1,6)
100 Z=Z+1
Where Z acts both as a flag and as a counter of the number of
times the program has been run, a very useful statistic!
4,9,2,4
Array Sizes
Arrays are limited in size only by HUNTER's memory space.
Remember that arrays compete with program for space,
automatically allocated by HUNTER's operating system.
Array size allocation is simplified by
self-sizing. For this
purpose, the Function FRE can be used as a variable. FRE
provides the number of memory bytes remaining as follows:
After NEW : The total memory available
After program entry: The memory available for data
After array definition: The memory remaining
The number FRE can be used to automatically calculate the max-
imum number of array elements possible for any given array type
and to sign on informing the operator of this information.
10 IF Z<>O THEN 100
20 N=2
30 Y=INT (((FRE(0)-7-N*7)/5)-1l
40 DIM A(Y)
100 PRINT ''TOTAL NUMBER OF ELEMENTS AVAILABLE:
11
,Y
Note that Y is taken as an integer (INT), that the symbol table
entry (-7) is subtracted, that the element size is 5 bytes and
that arrays start from zero, so the maximum number is one less
(-1 ). N*7 is an allowance for the number of variables used in
the subsequent program, assuming 7 bytes per variable.
NOTE: arrays can also be copied to files. See section 4.14.1
VER. V09F PAGE 4 - 27