pTAL Reference Manual (H06.03+)
Data Representation
HP pTAL Reference Manual—523746-005
3-13
Character String
string
is a sequence of one or more ASCII characters enclosed in quotation mark
delimiters. If a quotation mark is a character within the sequence of ASCII
characters, use two quotation marks (in addition to the quotation mark delimiters).
The compiler does not upshift lowercase characters.
Each character in a character string requires one byte of contiguous storage. The
maximum length of a character string you can specify differs for initializations and for
assignments.
Initializations
You can initialize simple variables or arrays of any data type with character strings.
When you initialize a simple variable, the character string can have the same number
of bytes as the simple variable or fewer. This example declares an INT variable and
initializes it with a character string:
INT chars := "AB";
When you initialize an array, the character string can have up to 127 characters and
must fit on one line. If a character string is too long for one line, use a constant list
(described Constant Lists on page 3-21) to break the character string into smaller
character strings.
Assignments
You can assign character strings to STRING, INT, and INT(32) variables, but not to
FIXED, REAL, or REAL(64) variables.
In assignment statements, a character string can contain at most four characters,
depending on the data type of the variable:
Number of Bytes in String Data Types to Which String Can Be Assigned
1 STRING, INT
2 STRING, INT
3INT(32)
4INT(32)
Example 3-6. Assigning Character Strings to Variables
string s;
int i;
s := "a"; ! OK
s := "ab"; ! OK: same as s := "b"
s := "abc"; ! ERROR: too big
i := "a"; ! OK
i := "ab"; ! OK: same as s := "b"
i := "abc"; ! ERROR: too big










