Dimension And Arrays; Filling Arrays - Epson FX Series User Manual

Fx series printer
Hide thumbs Also See for FX Series:
Table of Contents

Advertisement

DIMension and arrays

Most BASIC
S
array without any special preparation of the computer's memory.
Since arrays use up lots of memory, you must inform the system if you
intend to use a larger array. In BASIC, this is done with the DIMen-
sion statement, which is contained in the first line of the next program.
Enter:
NEW
10 DEFINT A: N=21: DIM A(N,N)
If your system rebels at line 10, use:
10 DEFINT A: N=21: DIM A(21,21)
The DIM statement in line 10 reserves enough memory for 21 rows
and 21 columns of numbers. That gives you a total of 441 cells. Each
cell takes up 2, 4, or 8 bytes, depending on the precision of the vari-
ables you use. The DEFINT restricts all variables that start with the
letter A to be of the integer type
ory.

Filling arrays

Most computer systems set to 0 all numeric variables, including
cells of arrays, at the beginning of a program. If your system does not
automatically do this, use the following lines to perform the same
function:
15 FOR X=0 TO N: FOR Y=0 TO N
17 A(X,Y)=0: NEXT Y: NEXT X
To plot a figure in memory after all the cells are set to zero, you simply
deposit ones in the correct positions using LET statements. For exam-
ple, the statement A(2,3) =l will place a one in location (2,3).
Suppose you want to plot a circle of radius 10 in the 21 row by 21-
column array-definitely a job for a plotter! You can, however, use
the standard distance formula (as in Figure 13-S) to calculate the dis-
tance from the center cell (11,11) to each of the surrounding cells. If
this distance is equal to 10, the cell content is changed to one; other-
wise, the cell value remains zero.
176
allow you to use up to 10 rows and 10 columns in an
(2
bytes); this definition saves mem-

Hide quick links:

Advertisement

Chapters

Table of Contents
loading

This manual is also suitable for:

Fx-100Fx-80Fx-185 - impact printer

Table of Contents