Title
Left ArrowCheats HomeRight ArrowCheats Misc ListCheats Number ListCheats A ListCheats B ListCheats C ListCheats D ListCheats E ListCheats F ListCheats G ListCheats H ListCheats I ListCheats J ListCheats K ListCheats L ListCheats M ListCheats N ListCheats O ListCheats P ListCheats Q ListCheats R ListCheats S ListCheats T ListCheats U ListCheats V ListCheats W ListCheats X ListCheats Y ListCheats Z List

Home Page

Projects...
PC Controller Box
Joystick Switch Box
c128D Refurb

Programs...
Byte Simulator
Cheat 'O Matic
GEOS

Collections...
3D Models
Book Collection

Information...
My BASIC Notes
Web Links

eMail Me

Note: You must add uk to the end of the address, it's to help prevent spam.

My BASIC Notes

Basic2 Commands
Disk Drives
ASCII and CHR$ Codes
PEEK's and POKE's
RAM Memory Map
ROM Memory Map
Screen Display
Sprite

DEF
Abbreviation: D <SHIFT+E>

TYPE: Statement
FORMAT: DEF FN <name> ( <variable> ) = <expression>

Action: This sets up a user-defined function that can be used later in the program. The function can consist of any mathematical formula. User defined functions save space in programs where a long formula is used in several places. The formula need only be specified once, in the definition statement, and then it is abbreviated as a function name. It must be executed once, but any subsequent executions are ignored.

The function name is the letters FN followed by any variable name. This can be 1 or 2 characters, the first being a letter and the second a letter or digit.

EXAMPLES of DEF FN Statement:

10 DEF FN A(X)=X+7
20 DEF FN AA(X)=Y*Z
30 DEF FN A9(Q) = INT(RND(1)*Q+1)

The function is called later in the program by using the function name with a variable in parentheses. This function name is used like any other variable, and its value is automatically calculated,

EXAMPLES of FN Use:

40 PRINT FN A(9)
50 R=FN AA(9)
60 G=G+FN A9(10)

In line 50 above, the number 9 inside the parentheses does not affect the outcome of the function, because the function definition in line 20 doesn't use the variable in the parentheses. The result is Y times Z, regardless of the value of X. In the other two functions, the value in parentheses does affect the result.


Commodore Cheetah made by Allen Monks, started in the year 2000.