Equates (constants):
PluriBASIC supports 5 kinds of equates:
- ENUM equates.
- Numeric equates.
- ANSI String equates.
- Duplicate equates (given they use a different data type)
- Unicode String equates.
The following 3 equates are acceptable, even when used in the same program:
%MYEQUATE = 1
$MYEQUATE = "Hello World"
$$MYEQUATE = "Hello Europe and Asia"
ANSI string equates cannot contain unicode strings, or unicode portions, as follows:
$ANSI_EQUATE = "Some unicode string"$$
But unicode equates can, so, the following syntax is valid:
$$UNICODE_EQUATE = "Some unicode string"$$
With String equates, you cannot use dynamic functions, but as long as you provide literals as parameters, you can use the functions that can be parsed at compilation time:
- CHR$
- SPACE$
- STRING$
- GUID$
Equates containing a
GUID, are checked at compilation time, and it has to be a valid value. Note that
CHR$$ cannot be used for equate creation, only its ANSI counterpart.
With numeric equates, the values are also calculated at compilation time, and they can consist of the following components:
- Numeric Expressions (1)
- HEXADECIMAL expressions (&h0001)
- OCTADECIMAL expressions (&o0001)
- BINARY expressions (&b0001)
- Another equates
- Aritmetic operators
ENUM equates are supported as well, the following syntax is addmitted:
ENUM EquatePrefix [
SINGULAR] [
BITS] [
AS COM]
EquateMember [= numeric_expression]
EquateMember [= numeric_expression]
[...]
END ENUMWhen using the
SINGULAR switch, the equates are generated without a prefix, but it still needs to be provided for internal diferentiation.
Currently the
AS COM switch is supported, but does nothing. The resulting equates may look as follows:
%EquatePrefix.EquateMember
Equates can be used in conditional compilation as follows:
#IF %DEF(%SOMEQUATE)
#IF NOT %DEF(%SOMEQUATE)
#IF %SOMEQUATE = 1
#IF %SOMEQUATE = %ANOTHEREQUATE
#IF %SOMEQUATE => 3.1
Etc.
System equates:
Currently the following system equates are defined, and require no external declaration.
- $NUL
- $BEL
- $BS
- $TAB
- $LF
- $VT
- $FF
- $CR
- $CRLF
- $EOF
- $ESC
- $SPC
- $DQ
- $DQ2
- $SQ
- $SQ2
- $QCQ
- $WHITESPACE
- %MAX_PATH
- %FALSE
- %TRUE
- %NULL
- $$NUL
Equates are not included in the final program unless used, just like MACROS, CLASSES, SUB, FUNCTION and UDTs.
Restrictions:
Equates defined inside a RAW segment are not taken into consideration for BASIC code outside the RAW sections, and they may conflict with system-generated equates.