EXAMPLE
DATA 100, 200, FRED, "WILMA"„ 3, 14. ABC123
DEF FN
DEF FN name (var.anle) = expression
This command allows you to define a complex calculation as a function.
In the case of a long formula that is used several times within a
program, this can save a lot of space.
The name you give the numeric function begins with the letters FN,
followed by any legal numeric variable name. First you must define the
function by using the statement DEF followed by the name you've given
the function. Following the name is a set of parentheses () with a
numeric variable (in this case, X) enclosed. Then you have an equal
sign. followed by the formula you want to define. You can "call" the
formula, substituting any number for X, using the formal shown in line
20 of the example below:
EXAMPLE.
10 DEF FNA(X)=12*(34.75-X/.3 +X
20 PRINT FNA(7)
The number 74s inserted each
pace X Is located in the formula
given in the DEF statement.
DIM
DIM variable (subscripts) (.variable(subscripts))
Before you can use an array of variables, the program must first
execute a DIM statement to establish the DIMensions of that array
(unless there are 11 or fewer elements in the array). The statement DIM
is followed by the name of the array, which may be any legal variable
name. Then, enclosed in parentheses, you put the number (or numeric
variable) of elements in each dimension. An array with more than one
dimension is called a matrix You may use any number of dimensions,
but keep in mind that the whole list of variables you are creating lakes
up space in memory, and it is easy to run out of memory it you gel
carried away. To figure the number of variables created with each DIM,
multiply the total number of elements in each dimension of the array
(Each array starts with element 0.)
NOTE: Integer (single-digit) arrays take up 2r5ths of the space of
floating point arrays.
EXAMPLE
10 DIM A5(40).B7(15).CC%(4, 4,4)
41 Elements
16 Elements
125 lements
You can dimension more than one array in a DIM statement by
separating the arrays by commas If the program executes a DIM
statement for any array more than once, you'll get a re'DIMed array
error message. It is good programming practice to place DIM
statements near the beginning of the program
NOTE: DEF FN can only be used with standard numeric functions.
not integer or string functions.
DO (LOOP) WHILE (UNTIL EXIT)
DOHINTIL boolean argument I
WHILE
bootean arguernentj
statements (EXIT)
114
1 1 5
Need help?
Do you have a question about the Commodore 16 and is the answer not in the manual?
Questions and answers