Requesting Waited Writes
Accessing Files
4–6
107365 Tandem Computers Incorporated
Requesting Waited
Writes
To open a file for waited write operations, issue a #REQUESTER call and include the
WAIT option. The following statement opens FILE1 and initializes
error_var
and
write_var
. If FILE1 does not exist, TACL creates an Edit file:
#SET rslt [#REQUESTER /WAIT/ WRITE file1 error_var write_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.
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 write operation is shared. For example:
#REQUESTER /EXCLUSION PROTECTED/ WRITE file2 error_var &
write_var
To initiate the write operation, append data to the write variable:
#APPEND write_var This is a test
When TACL detects data in
write_var
, it writes the data to FILE1.
You can add a record to a structured file but cannot replace a record. If you attempt to
write a record that already exists, TACL returns an error.
Each time you append a line to
write_var
, the TACL process writes the record to
FILE1. TACL continues executing code until it encounters an #APPEND(V) call that
refers to one of the #REQUESTER variables, signifying that you have more data to
write. TACL then waits until the current operation is complete before initiating the
next write operation.
When you are finished writing to the file, issue a CLOSE request and supply one of the
variable levels associated with the file; for example:
#REQUESTER CLOSE error_var
This operation closes FILE1 (associated with
error_var
) and terminates the
#REQUESTER function.