HP 3000 Manuals

Files [ HP Pascal/iX Programmer's Guide ] MPE/iX 5.0 Documentation


HP Pascal/iX Programmer's Guide

Files 

When your program declares a file, the compiler allocates space for the
file control block and the file buffer variable.  The amount of space
allocated to each is fixed by the packing algorithm.  The file is
8-byte-aligned.

Table 5-9  shows how the HP Pascal packing algorithm allocates file
components for textfiles and nontextfiles.

          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)              |
|                              |                |                                     |
---------------------------------------------------------------------------------------



MPE/iX 5.0 Documentation