Requesting Waited Reads
Accessing Files
4–2
107365 Tandem Computers Incorporated
Table 4-1 lists functions related to #REQUESTER operation.
Table 4-1. Functions Used With #REQUESTER
Function
Description
#APPEND, #APPENDV
Adds lines to a variable.
#EXTRACT, #EXTRACTV
Retrieves lines from a variable.
Requesting Waited
Reads
To open a file for waited read operations, issue a #REQUESTER call and include the
WAIT option; for example, the following statement opens FILE1 and initializes
error_var
,
read_var
, and
prompt_var
:
#SET rslt [#REQUESTER /WAIT/ READ file1 error_var read_var
prompt_var]
You can also use the WAIT option to specify the size of the text buffer. To specify
shared, protected, or exclusive access to the file, use the EXCLUSION option; the
default for a read operation is shared. For example:
#REQUESTER /EXCLUSION PROTECTED/ READ file2 error_var &
read_var prompt_var
Note
It is very important to check the results of the open operation; otherwise, you will not know if the open
request received an error.
To initiate a read operation, append data to the prompt variable:
#APPEND prompt_var *start read*
When reading a disk file, TACL discards the data in
prompt_var
; you can specify any
non-null data. TACL reads a record from FILE1 and places it into
read_var
. You can
use #EXTRACT(V) to retrieve data from
read_var
; as you #EXTRACT records,
TACL deletes them from
read_var
.
Each time you append a line to
prompt_var
, the TACL process reads a record from
the disk file FILE1 and appends it to
read_var
. TACL then performs a READ
operation. TACL continues executing code until it encounters an #APPEND(V) or
#EXTRACT(V) call that refers to one of the #REQUESTER variables. TACL then waits
until the current read operation is complete before initiating the next read operation.
When you are finished reading from the file, issue a CLOSE request and supply one of
the variable levels associated with the file; for example:
#REQUESTER CLOSE read_var
This operation closes FILE1 (associated with
read_var
) and terminates the
#REQUESTER function.