Strings [ HP Pascal/iX Programmer's Guide ] MPE/iX 5.0 Documentation
HP Pascal/iX Programmer's Guide
Strings
A string is allocated four bytes for its current length (an integer), one
byte per character, and one "housekeeping" byte. The number of
characters is the string's declared maximum length. The "housekeeping"
byte is only accessible to some of the standard string functions.
The HP Pascal packing algorithm aligns strings on 4-byte boundaries in
all structures. Because the current length (an integer) is allocated
four bytes, eight bytes is the smallest possible string allocation.
The formula for the number of bytes allocated to a string is:
Example
VAR
s1 : string[10];
s2 : string[7];
The string s1 takes 16 bytes:
(((4 + 10 + 1) + 3) DIV 4) * 4 =
(18 DIV 4) * 4 =
4 * 4 = 16
The allocation is:
The string s2 takes 12 bytes:
(((4 + 7 + 1) + 3) DIV 4) * 4 =
(15 DIV 4) * 4 =
3 * 4 = 12
The allocation is:
MPE/iX 5.0 Documentation