[Prev] [Next] [Contents] [Commodore] [New] [Search] [Home]

System Specification for C65Fred BowenMarch 1, 1991

DEF FN - Define function

        DEF FNname (numeric - variable) = numeric-expression

Define a user-written numeric function. The DEF FNx statement must be executed before the function can be used. Once a function has been defined, it can be used like any other numeric variable. The function name is the letters FN followed by any legal floating point (non-integer) variable name. A function can be defined only in a program.

The numeric variable is a "dummy" variable. It names the-variable in the numeric-expression which will be replaced when the function is used. It's-not required to be used in the numeric expression, and its value won't be changed by the function call. -

The numeric expression performs the calculations of the function. It is any legal numeric expression that fits on one line. Variables used in the expression have their value at the time the function is used.

Functions can be used only by the program which defines the if one program chains to another program, the first program's functions cannot be used (usually a 'SYNTAX ERROR' results). Similarly, if the program is moved in any way after the function is defined, the function cannot be used.

    10 DEF FNR(MAX) = INT(RND(0)*MAX)+1
    20 INPUT "MAXIMUM"; MAX
    30 PRINT FNR(MAX)

In this example, we've defined a function which will return a pseudo random number between I and whatever MAX is. Instead of using the expression INT(RND(0)*MAX)+1 every time a random number is needed, we can now use FNR(MAX). When we use FNR(x), the value of 'x' will be be substituted everywhere MAX is used in the function definition.

    10 DEF FNI(X) = X+1
    20 DEF FNL(Z) = LEN(A$)
    30 DEF FNAVG(N) = (TOT*CNT+N)/(CNT+1)

DELETE - Delete lines of BASIC program, or Delete disk files

        DELETE [startline] [-[endline]]
        DELETE "filespec" [,Ddrive] [<ON|,>Udevice] [,R]

There are two forms of DELETE. The first form is used in direct mode to remove lines from a BASIC program:

    DELETE 75 Deletes line 75.
    DELETE 10 - 50                    Deletes line 10 through 50 inclusive.
    DELETE - 50                       Deletes all lines from the beginning of
                                      the program up to and including line 50.
    DELETE 75-                        Deletes all lines from 75 to the end of
                                      the program.

The second form is used in program or direct mode to delete a disk file. See the SCRATCH command.

    DELETE "myfile"                   Deletes the file MYFILE on the system drive.

DIM - Declare array dimensions

    DIM variable(subscripts) [,variable(subscripts)] ...


[Prev] [Next] [Contents] [Commodore] [New] [Search] [Home]
This page has been created by Sami Rautiainen.
Read the small print. Last updated April 07, 2006.