[#IF [#FILEINFO/existence/ [dest]] | THEN |
[#LOOP | WHILE | [#EMPTYV do_i] | DO |
#INPUTV do_i "[dest] already exists! Would you like to purge it?"
[#CASE [do_i]
| Y | SINK [#PURGE [dest]]
| N |
| OTHERWISE | #SET do_i
]
]
#OUTPUT CREATING FILE.....
#SET create_err [FUP CREATE [dest], buffered, type E, rec 320, ext 40, maxextents 100] ==/ EXTENT 10, FILEFORMAT 1 /==ELIMINATE IF NOT NEEDED==
#SET do_i
[#IF create_err #RETURN] ==ELIMINATE IF NOT NEEDED==
]
== Open the source and destination files and
== associate variables with them.
#SET open_err [#REQUESTER /wait 320/ READ [source] read_err
read_var prompt_var]
[#IF open_err = 0 |THEN|
#OUTPUT [source] opened successfully
|ELSE|
#OUTPUT [source] not open; error [read_err]
#RETURN
]
#SET open_err [#REQUESTER /wait/ WRITE [dest] write_err
write_var]
[#IF open_err = 0 |THEN|
#OUTPUT [dest] opened successfully
|ELSE|
#OUTPUT [dest] not open; error [open_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|
== Set our COMPARE_STRING to the first 10 characters of the line
#SET cmp_str [#CHARGET read_var 1 for [max_l]]
== if the COMPARE_STRING is either the first or last text then we toggle
[#IF ("[#CHARGET cmp_str 1 for [f_length]]" '=' "[first_text]") | THEN |
toggle_out
]
[#IF ("[#CHARGET cmp_str 1 for [l_length]]" '=' "[last_text]") | THEN |
toggle_out
#SET read_err -1
]
== if Toggle is active, then we write out, otherwise keep going
[#IF [is_sending_out] |THEN|
== Wait for the last write to complete
SINK [#WAIT write_var]
== Move the record into write_var to initiate the
== write operation.
==#APPEND write_var [#EXTRACT read_var]
#EXTRACTV read_var write_var
#SET lines_copied [#COMPUTE [lines_copied] + 1]
| ELSE |
#EXTRACTV read_var dump_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]