String Equates

You can define string equates by prefixing a dollar-sign ($) to the equate data name.  The value on the right side of the string equate must be a string literal, or an expression made of string literals.  A string literal can also be constructed with combinations of the expanded CHR$ function, the STRING$ function, the SPACE$ function, the GUID$ function, and string constants.  For example:

$Name      = "John Smith"

$Fullname  = "John" & " Smith"

$UserName  = $First & $Last

$PrintCode = CHR$(27, 34, "E") + SPACE$(10) + CHR$(65 TO 90)

$AppGuid   = GUID$("{01234567-89AB-CDEF-FEDC-BA9876543210}")

A string equate can include the double-quote character, simply by doubling the character within the string.  For example:

$ABC = "This is a ""string"""

String equates are individually limited to 255 characters.  Attempting to create a longer string equate will trigger a compile-time Error 489 ("Invalid string length").

As with numeric equates, PowerBASIC pre-calculates the string equate content during compilation to avoid unnecessary concatenation operations at run-time.  Duplicate definitions of both numeric and string equates are permitted by PowerBASIC, provided the actual content is identical.  If the content is not identical, a compile-time Error 468 ("Duplicate Equate") will occur.

String equates must be created outside of any SUB, FUNCTION, METHOD, or PROPERTY.  String equates are global, and may be referenced anywhere in the module.

 

See Also

Constants and Literals

Defining Constants

Numeric Equates

Built-in numeric equates

Built-in string equates