Download HP Pascal for OpenVMS Language Reference Manual

Transcript
9.8.10 LOCATE Procedure
The LOCATE procedure positions a random-access file at a particular
component so that the next PUT procedure can modify that component.
LOCATE( file_variable, component-number [[, ERROR := error-recovery]] );
file_variable
The name of the file variable associated with the file to be positioned.
component-number
A positive integer expression that indicates the relative component number of
the component to be found.
error-recovery
The action to be taken if an error occurs during execution of the routine.
The file can be in any mode before LOCATE is called. The mode is set to
generation after the procedure’s execution.
The LOCATE procedure positions the file so that the next PUT procedure
writes the contents of the file buffer into the selected component. After
LOCATE has been performed, UFB returns TRUE and EOF is undefined.
Because the LOCATE procedure does not perform an I/O operation, the value
returned by the STATUS procedure is unaffected by LOCATE.
Consider the following example:
LOCATE( Accounts_Receivable, 63 );
Accounts_Receivable^ := Next_Account;
PUT( Accounts_Receivable );
The LOCATE procedure positions the file Accounts_Receivable before relative
component number 63. The call UFB( Accounts_Receivable ) now returns
TRUE and EOF( Accounts_Receivable ) is undefined. The assignment
statement loads the file buffer with the contents of file position 63. The
PUT operation writes the file buffer into file component number 63.
UFB( Accounts_Receivable ) remains TRUE.
For More Information:
•
On relative files (Section 9.1.2)
•
On random access by relative component number (Section 9.3.2)
•
On the UFB function (Section 9.8.22)
Input and Output Processing 9–43