HP Pascal/iX Reference Manual (31502-90022)

3- 27
String Assignment Compatibility
Certain restrictions apply to the assignment of string literals or
variables of the type string, PAC, or char. These restrictions are
listed below.
* If T1 is a string variable, T2 must be a string variable or a
string literal whose length is equal to or less than the maximum
length of T1. T2 cannot be a PAC or char variable. Assignment
sets the current length of T1.
* If T1 is a PAC variable, T2 must be a PAC or a string literal
whose current length is less than or equal to the length of T1.
T1 is blank filled if T2 is a string literal or PAC that is
shorter than T1. T2 cannot be a string or a char variable.
* If T1 is a char variable, T2 may be a char variable or a string
literal with a single character. T2 cannot be a string or PAC
variable.
Table 3-1 summarizes these rules. The standard function
strmax(s)
returns the maximum length of the
string
s. The standard function
strlen(s)
returns the current length of the
string
s or the number of
characters in the PACs.
String constants
are considered string literals when they appear on the
right side of an assignment statement. Any string operation on two
string literals, such as the concatenation of two string literals,
results in a string of type string.
Table 3-1. String, PAC, and String Literal Assignment
------------------------------------------------------------------------------------------------
||||||
| T1:=T2 | string | PAC | char | String Literal |
||||||
------------------------------------------------------------------------------------------------
||||||
| string | Only if | Not allowed | Not allowed | Only if |
| | strmax(T1)>= | | | strmax(T1)>= |
| | strlen(T2) | | | strlen(T2) |
||||||
------------------------------------------------------------------------------------------------
||||||
| PAC | Not allowed | Only if | Not allowed | Only if |
| | | strlen (T1) >= | | strlen (T1) >= |
| | | strlen (T2) | | strlen(T2) |
| | | T1 is padded | | T1 is padded |
| | | with blanks | | with blanks |
| | | if necessary | | if necessary |
||||||
------------------------------------------------------------------------------------------------
||||||
| char | Not allowed | Not allowed | Yes | Only if |
| | | | | strlen(T2)=1 |
||||||
------------------------------------------------------------------------------------------------