HP Business BASIC/XL Reference Manual - HP 3000 MPE/iX Computer Systems - Edition 1 (32715-90001)

4- 38
The following are examples of declaring variables of types DECIMAL and
SHORT DECIMAL.
100 SHORT DECIMAL Price
120 SHORT DECIMAL Cost1,Cost2(7),Cost3
130 DECIMAL Length
140 DECIMAL D1,D2,D3(6,8),D4(3,5)
DEF FN
The DEF FN statement defines the beginning of a multi-line function. It
is not executable.
Syntax
Numeric function:
DEF [
type
] FN
identifier
[(
f_param
[,
f_param
]...)]
String function:
DEF FN
identifier
$ [(
f_param
[,
f_param
]...)]
Parameters
type
Numeric type (for example, INTEGER, SHORT REAL). If
type
is specified, the numeric function returns a numeric
value of that type. If
type
is not specified, the
numeric value returned has the default numeric type. A
string function returns a string value.
FN
identifier
, Function name. A blank is not allowed between FN and
FN
identifier
$ the identifier. For example, if the identifier is Add,
the function name is FNAdd or FNAdd$.
f_param
A formal parameter. Formal parameters for multi-line
functions are specified like as they are for
subprograms. The SUBPROGRAM statement explains the
specification.
Example
DEF INTEGER FNAdd (INTEGER A,B(*), REAL C,D(*), E$(*,*,*),F$,G)
DEF FNSearch$(E$(*,*,*),F$, G, #20)
Each of the above statements defines the beginning of a multi-line
function. FNAdd is a numeric (type INTEGER) function, and FNSearch is a
string function.
Each has the following formal parameters:
Parameter Type
A Scalar integer variable
B Integer array variable
C Scalar real variable
D Real array variable
E$ String array variable
F$ Scalar string variable
G Scalar variable with the default numeric type
#20 File designator
If a program has more than one multi-line function with the same name,
the name refers to the first function with that name; that is, the one
that has the lowest-numbered DEF FN statement. The others cannot be
called.
If a program unit has a single-line function with the same name as a
multi-line function, that program unit can only call the single-line
function. Other program units can still call the multi-line function.
DEFAULT OFF
Values that are out of range cause arithmetic errors, explained under the
DEFAULT ON statement. The DEFAULT ON statement overrides those error