DEF Verb - BBj


For this topic's original documentation, see DEF Verb.

BBj-Specific Information

Syntax

DEF FNintname%(arglist){=integer}

DEF FNobjname!(arglist){=expr}

Description

In addition to user-defined numeric and string functions, BBj also supports user-defined integer and object functions.

Parameter

Description

FNintname%

Integer function

FNobjname!

Object function

arglist

Series of simple variables separated by commas

=integer

Integer numeric expression

=expr

Any expression. This can be any number, string, or object.

Examples

Example 1

An integer function must return a numeric expression. If the numeric expression does not evaluate to an integer, !ERROR=41 is reported at runtime.

rem ' define integer function

DEF fnx%(x%)=x%

rem ' invoke integer function
let i%=fnx%(123)

Example 2

An object function can return any expression, including any numeric, string, or object expression.

rem ' define object function

DEF fnx!(x!)=x!

rem ' invoke object function
let x=fnx!(2*2)
let PI=fnx!(java.lang.Math.PI)
let x$=fnx!('GREEN')
let i!=fnx!(new java.lang.Integer(123))

See Also

Verbs - Alphabetical Listing