The Mysterious “DEF FN and FN” Functions

Authors

Publication

Pub Details

Date

Pages

BASIC Terms

See all articles from Update April 1988

One Monday morning at the Timex Literature Department Mary was given a task that would normally been assigned to Gus, the Mathematician. Gus had his usual Monday morning problem. Now Mary majored in Greek Literature, not Greek Mathematics symbols. But, never the less, Mary was given the task of writing the part of Appendix A of the TS-2068 User Manual to explain such functions as ABS, ACS, ATN, “DEF FN”, and “FN”. Thus explains the reason why many TS-2068 users have not ever used the DEF FN and FN functions. The User Manual has good prose, but lacks some in detail.

The two functions DEF FN and FN are used together like bread and butter to store MATH FORMULAS in memory and then SOLVE the problems by INPUT of the missing factor. Take for example the formula C=PI*D for solving the circumference of a circle when d (diameter) is known. To set the formula into memory, a line of programming would define the formula as, DEF FN c(m)=PI*d. Or, to convert METERS to INCHES, the formula I=39.37*M would be defined in a program line as, DEF FN i(m)=39.37*m. The formula is in the DEF FN structure, and the SOLUTION is achieved by using the FN function, as PRINT FN i(m), or LET a= FN i(m), to assign to a variable.

The following little program demonstrates one way of using the DEF FN and FN functions.

1 REM ** Using DEF FN and FN **
10 PRINT "Convert Meters to Inches"
20 DEF FN i(m)=39.37*m
30 INPUT "Diameter in Meters? ";m
40 PRINT FN i(m)
50 LET d= FN i(m)
60 PRINT "Compute Circumference"
70 DEF FN c(m)= PI *d
80 PRINT FN c(m)

SYNTAX: DEF FN is followed by a identifier, “i” in the first case, and “c” in the second case. Then the designator letter is inclosed (m). This also can be any letter. On the right side of “=” comes the formula to be solved. The un-known factor in the formula, “m” in the first case, and “d” in the second case, are fed into the formula by INPUT prompt. Line 40 gets the value computed with the “PRINT FN i(m)”. Line 50 demonstrates that the FN solution may be directly assigned to a variable. This value of d is used in the second formula to compute the circumference of a circle.

The DEF FN formulas may be placed in a line of programming to be initialized as one initializes a variables table (with GO SUB line #). The DEF FN formulas need not be repeated once they are initialized. Variable Not Found report will result if there are insufficient inputs for the formula to be solved.

Products

 

Media

 

Image Gallery

Source Code

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

Scroll to Top