String Literals [ HP Pascal/iX Reference Manual ] MPE/iX 5.0 Documentation
HP Pascal/iX Reference Manual
String Literals
String literals are sequences of characters, enclosed by single quote
marks, that may not be longer than a single line of source code. String
literals may consist of any combination of the following:
* A sequence of ASCII characters enclosed in single quote marks.
* A sharp symbol (#) followed by a single character.
* A sharp symbol (#) followed by up to three digits that represent
the ASCII value of a character.
A letter or symbol after a sharp symbol is equivalent to a control
character. For example, #G or #g encodes CTRL-G, the bell character.
The compiler interprets the letter or symbol according to the expression
chr(ord(letter) MOD 32). Therefore, the ordinal value of G is 71;
modulus 32 of 71 is 7; and the ASCII value of 7 is the bell.
In a string literal, if a number is used after a sharp symbol, it may
contain up to three digits, but must be in the range 0 through 255. It
directly encodes any printing or nonprinting ASCII character. For
example, the string literal #80#65#83#67#65# 76 is equivalent to the
string literal PASCAL.
Any ASCII character can appear between quote marks. The sharp symbol #
is provided to enable better documentation of nonprinting characters.
A string literal may be type char, PAC, or string. This is dependent on
the context in which it is used. If a single quote is a character in a
string literal, it must appear twice, consecutively.
Two consecutive quote marks ('') are used to specify the null or empty
string literal. Assigning this value to a string variable sets the
length of the variable to zero. Assigning this value to a PAC variable
blank-fills the variable.
Syntax
String_literal:
Example
'Please don''t!' { Single quote character. }
'A'
'' { Null string. }
#F
#243#H
#27'that was an ESC char, and so is this'#[
'this string has five bells'#G#g#g#7#7' in it'
MPE/iX 5.0 Documentation