FUNCTION name (parameter list) [AS INTEGER | AS
STRING | AS SINGLE]
parameter list = parameter [, parameter list]
parameter = [BYVAL] paramname [AS INTEGER]
| [BYVAL] paramname AS SINGLE
| [BYVAL] paramname(size)
AS
STRING
| BYREF paramname AS
STRING
| BYREF
paramname() AS
STRING
| [BYREF] paramname()
[AS INTEGER]
| [BYREF] paramname() AS SINGLE
Used as a modifier in parameter declarations for FUNCTIONs or SUBs.
BYREF passes a pointer to the parameter to the FUNCTION or SUB. This allows a function to read AND write the original source parameter.
An advantage in BYREF use with STRINGs, is that extra space is not required and the STRING does not have to be copied for the FUNCTION or SUB procedure. Constant strings may be passed BYREF, but any code that attempts to modify a constant string will cause a Data Abort.
BYVAL is assumed if nothing specified for single variables or STRINGs
Arrays of INTEGERs or SINGLEs can be passed, but are always passed BYREF, so the BYREF modifier is optional.