FNx() Function - Execute User-Defined Function

Syntax

FNnumname(expr,...)
FNstrname(expr,...)

Description

For BBj-specific information, see FNx() Function - BBj.

Used with the DEF verb, the FN() function executes functions defined by the user.

Parameter

Description

FNnumname

Any valid numeric variable name, as specified in the corresponding DEF verb. Returns a numeric value.

FNstrname

Any valid string variable name, as specified in the corresponding DEF verb. Returns a string value.

expr

Numeric or string that corresponds to the argument list used for the DEF verb. Variables used in functions can be changed by the function.

Because the argument list on the define is only prepared to accept simple variables, a string dimensioned to a template will only pass the value of the string to the receiving variable and not the template definition. In addition, an array reference may only contain a single element of an array and not pass an entire array. If a procedure requires passing arguments by reference, it should use the interface defined by the CALL verb.

Examples

Example 1

The following converts decimal hours to minutes:

0100 DEF FNTIME$(X)=STR(INT(X)-12*(INT(INT(X)/13)
0100:))+":"+STR(INT(FPT(X)*60))":00"
>PRINT FNTIME$(TIM)

12:56

Example 2

The following inserts slashes in the date:

0100 DEF FNDATE$(X$)=X$(1,2)+"/"+X$(3,2)+"/"+X$(5,2)
>PRINT FNDATE$("091596")
09/15/96

See Also

Functions - Alphabetical Listing