Requesting Nowaited Reads
Accessing Files
4–4
107365 Tandem Computers Incorporated
Requesting Nowaited
Reads
To open a file for nowaited read operations, issue a #REQUESTER call and omit the
WAIT option; for example, the following statement opens FILE1 and initializes
error_var
,
read_var
, and
prompt_var
:
#SET rslt [#REQUESTER READ file1 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 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
To initiate a read operation, append data to the prompt variable:
#APPEND prompt_var *start read*
To read a disk file, TACL discards the data in
prompt_var
, 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
disk file FILE1 and appends it to
read_var
. TACL then performs a READ operation.
TACL continues executing code; when you are ready to wait for completion of the
read operation, use the #WAIT built-in function to wait until
read_var
contains
data. To avoid writing over data that has not yet been transmitted, use #WAIT to
make sure the previous operation has finished.
When you are finished reading from the file, issue a CLOSE request and supply one of
the variables associated with the file; for example:
#REQUESTER CLOSE error_var
This operation closes FILE1 (associated with
error_var
) and terminates the
#REQUESTER function.
Use the routine in Figure 4-2,
nowaited_read
, to perform nowaited reads from the
file specified in the first argument in the invocation and display the records on the
terminal. To invoke this routine, load the file and type:
nowaited_read
filename