Strings

A string is a sequence of characters of a given length. PRO/5 supports strings from a minimum length of zero to a maximum length limited only by the size of the workspace. A string may contain any data. PRO/5 will never find special meaning of certain characters within a string during string manipulation.

String Constants

There are three different kinds of string constants in PRO/5: character, hexadecimal (hex), and mnemonic.

String Constant

Description

Character

A character string constant must be enclosed in quotation marks (" "). For the sake of portability, the programmer should use only alphabetic characters, digits, punctuation characters, and spaces in character strings. If a quotation mark is desired in a character string, it must be represented by two adjacent quotation marks. Some examples follow:

"The quick brown fox"
"The "" is a funny character"
"" null string

Hexadecimal

Hexadecimal string constants are enclosed in dollar signs. The only characters allowed in hex constants are 0..9, A..F, and a..f. Each character in a hex string represents an internal 4-bit value. Two hex characters represent one byte. Therefore, the internal length of a hex constant is half the number of characters in the constant. A hex constant must contain an even number of characters between the dollar signs. Some examples are:

$0123456789ABCDEF$
$50524F2F35$ equivalent to "PRO/5"
$$ null string

Mnemonic

Mnemonic constants are used for input/output device control. Normally they are used with input/output verbs, but they may be used as a legal string value anywhere. Actually, a mnemonic is part constant and part variable, depending on how it is used.

A mnemonic has two different forms.

  • A sequence of characters enclosed in tick marks (''). The character sequence may be from 2 to 16 characters long. Only A..Z, 0..9, and _ (underscore) may be used. Some examples:

'CS'
'GREEN'

A parameter list may optionally follow these mnemonics. The parameter list may be any sequence of numeric and string expressions enclosed in parentheses. If the parameter list is not meaningful, unpredictable results may occur when outputting the mnemonic. Some examples:

'BOX'(10,12,4,4)
'FONT'("pica")

  • The "positioning" mnemonic. It consists of an at-sign (@) followed by one or two numeric expressions enclosed in parentheses:

@(X,Y+3)
@(40)

The internal format of mnemonic constants should not concern the programmer. They should be used only for device control. The legality of a mnemonic depends entirely on the device being used. See Character Devices - Overview for a discussion of the various mnemonics that may be used.

String Variables

String variables are named following the same rules described under Numeric Constants, Variables, and Arrays except that a dollar sign must always appear at the end of the name. Some examples are: A$, NAME$, ADDRESS1$. A string variable may contain any sequence of characters up to the size of the workspace. Any reference to a string variable that has not been explicitly assigned a value will result in a null string with a length of zero. This behavior may be modified using SETOPTS.