11. Functions
A function is a single statement or group of statements that
perform operations on operands and return the result to your
program. BASIC has built-in functions that perform nu-
meric and string operations, conversions, and date and time
operations. This chapter describes only a selected group of
built-in functions. For a complete description of all BASIC
built-in functions, see the DEC BASIC and VAX BASIC for
OpenVMS Systems Reference Manual .
This chapter also describes user-defined functions. BASIC
lets you define your own functions in two ways:
.
With the DEF statement
.
As separately compiled subprograms (external functions)
DEF function definitions are local to a program module,
while external functions can be accessed by any program
module. You create local functions with the DEF statement
and optionally declare them with the DECLARE statement.
You create external functions with the FUNCTION state-
ment and declare them with the EXTERNAL statement. For
more information about creating external functions with the
FUNCTION statement, see Chapter 13.
Once you create and declare a function, you can invoke it like
a built-in function.