String Equates

You can create a string equate by prefixing $ (for ANSI) or $$ (for WIDE) to the equate name. The value on the right side of the equate assignment must be a string literal, or an expression created from string literals. The string literal expression can be constructed from combinations of other string equates or quoted string literals, the CHR$ function, SPACE$ function, and the STRING$ function when used with numeric parameters. ANSI string equates can also use the GUID$ function. For example:

$Name = "John Smith"

$$Fullname = "John"$$ & " Smith"$$

$$UserNam = $$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"""

ANSI string equates are each limited to 255 characters, while WIDE equates are limited to 127 characters. An attempt 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 limit calculations 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 be generated.

A string equate name must always begin with one or two leading dollar signs ($) and a letter (A-Z). This is optionally followed by any combination of letters (A-Z), numbers (0-9), and underscores (_). All other characters are illegal.

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. For readability, we suggest placing equates at the top of your code.

See Also

Constants and Literals

Defining Constants

Numeric Equates

Built-in numeric equates

Built In RGB Color Equates

Built-in string equates