HP Pascal/iX Programmer's Guide (31502-90023)
5-: 22
Table 5-9. Allocation of File Components
(HP Pascal Packing Algorithm)
---------------------------------------------------------------------------------------
|| ||
| File Component | Textfile | Nontextfile |
|| ||
---------------------------------------------------------------------------------------
|| ||
| Control block | 324 bytes | 320 bytes |
|| ||
---------------------------------------------------------------------------------------
|| ||
| Buffer variable | 254 bytes | Size of component type |
|| ||
---------------------------------------------------------------------------------------
Sometimes you can reduce file buffer size or increase file operation
speed by the way you declare a file. Compare the following file
definitions, their buffer sizes, and how you can write 100 integers to
them.
---------------------------------------------------------------------------------------
| | | |
| Declaration | Buffer Size | How to Write 100 Integers to the |
|||File |
| | | |
---------------------------------------------------------------------------------------
| | | |
| | | |
| VAR | 4 bytes | FOR i:=1 TO 100 DO write(f,i); |
| f : FILE OF integer; | | |
| | | (100 calls to
put
)|
| | | |
---------------------------------------------------------------------------------------
| | | |
| | | |
| VAR | 400 bytes | FOR i:=1 TO 100 DO f^[i]:=i; |
| f : FILE OF | |
put
(f); |
| ARRAY [1..100] | | |
| OF integer; | | (One call to
put
)|
| | | |
---------------------------------------------------------------------------------------
Sets
The HP Pascal packing algorithm allocates sets in units called
set
chunks
. Set chunk size depends on the number of bits required to
represent the set and whether the set is unpacked, packed, or crunched.
The number of bits required to represent the set is determined by the
formula:
bits_required_for_set
= ord(
largest_value_in_set
) -
ord(
smallest_value_in_set
) + 1
Table 5-10 shows how the HP Pascal packing algorithm determines set
chunk size.