Commodore 2001-8 User Manual page 57

Table of Contents

Advertisement

The subscripted values V(O), V(l), ...,V(B) are the GNP's for each of the 9 years. The subscripted strings
A$(O), A$(1),...A$(7) give accuracy to the graph by printing these graphics:
string
prints
A$(O)
null(by
default)
A$(l)
I
A$(2)
A$(3)
A$(4)
A$(5)
-
A$(6)
-
A$(7)
THE HEADING
ASC
165
180
181
161
182 (R)
170 (R)
167 (R)
GROSS NATIONAL PRODUCT
(IN $BILLIONS)
is printed in lines 50and 60 and then a FOR·NEXT loop on lines '100-140 prints out the eight bars. Line 120
prints out each bar and line 130 prints a cursor up and then the associated year, STR$(66
+
I) and GNP,
STR$(V(I)).
Each bar is made up of Y reverse field spaces and the string A$(B*(X·Y)). The Y is determined by the
formula
Y
=
INT(V(lV45,
=
INT (GNP/45)
Here, 45 is purely a scale adjustment. The proportions of the bars remain the same when values other
than 45 are used.
Fine tuning on the bar length is accomplished using the subscripted string variable
A$(8'(X-Y))
Here B*(X·Y) will range over the decimal values 0 through 7.99...9 but A$ automatically truncates the
decimal part.
DIMENSION STATEMENTS
When using more than 10 subscripts for any variable, a dimension statement must be given. It takes the
form, DIM A$(K), where K is the largest subscript of A$ used in the program. When variables are
redimensioned without a CLR statement or when a dimension statement appears after the variable has
been used, a ?REDIM'D ARRAY ERROR occurs. When a dimension statement is made, space is reserved
in memory for the given number of variables, including the variable whose subscript is O. It is good
programming sense, therefore, to begin subscripts at 0 and not 1.
Because the variables are divide in storage between arrays and simple variables insertion of an
additional simple variable Is a bit more complicated once an array has been defined. First, the entire array
storage area must be block moved upward by seven bytes and the pointers adjusted upward
+
7. Finally,
the simple variable can be Inserted at the end of simple variable storage.
53

Advertisement

Table of Contents
loading

This manual is also suitable for:

Pet 2001-8

Table of Contents