![background image](http://html.mh-extra.com/html/hp/tacl/tacl_programming-manual_2175295099.webp)
Copying Records Between Files
Accessing Files
107365 Tandem Computers Incorporated
4–11
Figure 4-5. Copying Records From One File to Another File (Page 2 of 2)
[#IF open_err = 0 |THEN|
#OUTPUT [dest] opened successfully
|ELSE|
#OUTPUT [dest] not open; error [write_err]
SINK [#REQUESTER CLOSE read_var] == close source
#RETURN
]
== Initiate read and write operations.
#SET read_err 0 == initialize read_err
[#LOOP |DO|
== Start the read.
#APPEND prompt_var READIT
== Wait for read_var or read_err to change.
#SET ready [#WAIT read_var read_err]
== If read_var changed, the read was successful.
[#IF [#MATCH read_var.* [Ready]] |THEN|
== Wait for the last write to complete
SINK [#WAIT write_var]
== Move the record into write_var to initiate the
== write operation.
#EXTRACTV read_var write_var
]
|UNTIL| ([read_err])
] == end of #loop
== Wait for the last write operation to finish.
SINK [#WAIT write_var]
== Close both files and terminate the #REQUESTER
== functions.
SINK [#REQUESTER CLOSE read_var]
SINK [#REQUESTER CLOSE write_var]
|2|
#OUTPUT *** Error: Invalid destination filename ***
]
|2|
#OUTPUT *** Error: Invalid source filename ***
]
#UNFRAME
The #EXTRACTV call that performs the write operation clears the contents of
read_var
and
write_var
. TACL moves a record out of
read_var
and into
write_var.
After TACL writes the data, TACL deletes the record from
write_var
.