Syntax
|
define-directive: |
<variable-definition> |
|
<function-definition> |
|
<default-visibility-set> |
| variable-definition:
| (define | :) [private | protected | public] <ident> [[ <expr> ]] [[=] <expr>] |
| function-definition:
| (define | :) [private | protected | public] <ident> ( [<formal-function-args>] ) <expr> |
| default-visibility-set:
| (define | :) private | protected | public |
| formal-function-args:
| <formal-function-arg> [, <formal-function-arg>]... |
| formal-function-arg:
| <by-val-arg> | <by-ref-arg> |
|
by-val-arg: |
[<value-type-id>] <ident> [= <expr>] |
|
<func-or-array-type-id> <ident> |
| by-ref-arg:
| [<value-type-id>] * <ident> |
| value-type-id:
| any | int | str |
| func-or-array-type-id:
| func | array |
Description
The first syntax ("variable-definition") defines a variable named ident, or assigns a value to an element of an array named ident (use dim instead of define to define the array variable itself). If none of the public, protected, or private keywords are specified, default visibility is assumed.
The second syntax ("function-definition") defines a user defined function named ident. Note:
- There must be no whitespace between the name and the opening parenthesis, otherwise it will be treated as a variable declaration.
- Formal parameters may be preceded by a type-id: any, int, str, func, or array.
- Default values may be specified only for parameters with no type-id or with type-id: any, int, or str.
- The func type-id declares that the parameter accepts a user defined function or built-in function, and the array type-id declares that it accepts an array variable. When calling such a user defined function, the actual parameter for a func or array parameter must be specified using the @ operator (for example, @MyFunc or @MyArray). Also see User Defined Functions.
The third syntax ("default-visibility-set") sets the default visibility of further variable and user defined function definitions in this file. If no visibility declaration occurs in a file, public visibility is assumed by default.
Examples
#define MyAppName "My Program"
#define MyAppExe MyAppName + ".exe"
#define MyAppVer GetVersionNumbersString(MyAppExe)
#define MyArray[0] 15
#define Multiply(int A, int B = 10) A * B
See also
dim, undef, Visibility of Identifiers
User Defined Functions