Futurebasic/Language/Reference/Define
#Define
[edit | edit source]Statement
[edit | edit source]✔ Appearance ✔ Standard ✔ Console
Syntax
[edit | edit source]#define newTypeName as oldTypeName #define newTypeName as {pointer to|@|^|.} oldTypeName #define newTypeName as {handle to|@@|^^|..} oldTypeName
Description
[edit | edit source]The #define
statement is one way to create a name for a variable type (the other way to do so is to use the begin record
statement). newTypeName
can be any new name you like that is different from the names of all existing types. oldTypeName
is the name of an existing type; this can either be a built-in type such as Rect
or Int
, or a type which you created previously, in a begin record
statement or in another #define
statement. After the #define
statement, you can declare variables of the new type using dim
statements, and you can pass newTypeName
to
the sizeof
and typeof
functions.
If you use the first syntax, newTypeName
essentially becomes a synonym for oldTypeName
. If you use the other two syntaxes, then variables of the new type are recognized as pointers or handles to structures of oldTypeName
. This is the only way to create a type name for pointers or handles to other types.
Notes
[edit | edit source]#define
is non-executable, so you can’t change its effect by putting it inside a conditional
execution structure such as long if...end if
.
A non-executable statement inside a compile long if
block will only be compiled if the
condition following the if
is met. Otherwise it will be ignored.