String Expressions

String data consists of a sequence of ASCII characters. They can represent either numeric or nonnumeric information, and are limited in length to 248K.

Character string constants consist of a sequence of ASCII characters enclosed in apostrophes ('), double quotation marks ("), or backslashes (\). Some examples of character string constants are:

"EMILY DANIELS"

'$42,368.99'

'NUMBER OF EMPLOYEES'

"34 CAIRO LANE"

\"FRED'S PLACE" ISN'T OPEN\

The beginning and terminating delimiters must match. In other words, if you begin a string with a single quotation mark, you must use a single quotation mark to terminate the string. If one of the delimiters is used within the character string, a different delimiter must be used to begin and terminate the string. For example, using apostrophes to enclose the following string is incorrect:

'IT'S A LOVELY DAY.'

Instead, the string should be delimited with double quotes (or backslashes), as follows:

"IT'S A LOVELY DAY."

Two adjacent identical delimiters specify a null, or empty, string. Any ASCII character can be used in character string data except the ASCII character 10 (carriage return), which is used to separate the logical lines of a program.

The CAT String Operator

String expressions can be concatenated, or linked, by using the concatenation operator (: or CAT) as follows:

NAME = FIRST : LAST

or

NAME = LAST CAT ", " CAT FIRST

If, for instance, the current value of FIRST is JANE and the current value of LAST is GREY, the preceding string expressions have the values:

" JANE GREY "

" GREY, JANE "

Multiple concatenation operations are performed from left to right. Expressions in parentheses are evaluated before other operations are performed.

All operands in concatenated expressions are considered to be string values regardless of whether they are string or numeric expressions. However, the priority of arithmetic operators is higher than the concatenation operator. If both types of operator appear in the same expression, arithmetic operations are performed first.

For example:

"JANE IS" : "2" + "2" : "3" : "YEARS OLD."

has the value:

"JANE IS 43 YEARS OLD."

See Also

Building Expressions

Simple Assignment

Using Operators and Functions

Numeric Expressions

Logical Data (Booleans)