DEF FN (Statement)


Declare a user-defined function.


DEF FN <functionname>[<suffix>] = <constant>
DEF FN <functionname>[<suffix>](<argument>[,<argument>...]) = <arithmetic expression>


This statement declares a <functionname> starting with FN as a user defined function.
<argument> is a variable name to be used in <arithmetic expression>. A different variable type with the same variable name cannot be declared.
Specifying <suffix> declares also the variable type. <suffix> is any of the following.
Integer suffix:
%
Single-precision suffix:
!
Double-precision suffix:
#
String suffix:
$

<suffix> can be omitted. Omitting it regards the user-defined function as a single-precision variable of type real.


DEF FND$ = "DENSO"
'Declare FND$ as a user defined function
DEF FNLAP# (radius) = 2 * PI * radius
'Declare FNLAP# (radius) as a user defined
'function of the double precision real type
DEF FNAREA (radius) = PI * POW(radius, 2)
'Declare FNAREA (radius) as a user defined
'function of the single precision real type
PRINT #1, FND$
'Output "DENSO" from ch1
PRINT #2, HANKEI
PRINT #1, FNLAP# (HANKEI)
'Output the value of (2*PI*HANKEI) from ch1
PRINT #2, FNAREA (HANKEI)
'Output the value of (PI*POW(HANKEI,2) from ch2


Top