COPY/COPYIN

 

Syntax:

       Then: COPY filename
       Then: COPY lookupname TO lookupname

       Then: COPYIN filename

       Then: COPY lookup1 TO lookup2

v6.2 (6.1.02 USP)
       Then: COPY array
       Then: COPYIN array
       Then: COPY array TO lookup
       Then: COPY lookup TO array
       Then: COPY array1 TO array2

Once you have used a lookup statement to open a record in another file (or your current file), any of the first three of these commands can be used. The COPY command copies the entire current record to the looked-up record. (The maps of each file must match each other exactly with respect to field lengths and edit types. The destination map can be bigger than the source map as long as the fields match between files from the beginning of each file to the point where the destination map adds more fields.) The fields are copied one for one so that the destination record becomes a duplicate of the current record (COPY) or the current record becomes a duplicate of the source record (COPYIN). If you have used lookup to open two files simultaneously, you can use the fourth syntax shown above to COPY a record from one lookup to the other or vice versa.

 

Note: It is prudent to do a WRITE immediately after COPY or COPYIN to ensure that the record has been completely copied and the transaction has been handed to the O/S. COPY has great usefulness when creating archive files since it will copy an entire record with only one command. You don't have to do it field by field.

 

NEW in Version 6.0 and higher:  ARCHIVE

 

Automatic indexes are automatically updated, if need be, when COPY or COPYIN is used.

 

Version Ref:  3.x (modified in version 4.5 to add copy one lookup to another)

Description:

COPY works in conjunction with the LOOKUP command, to copy all fields in the current record to a record in a looked-up file, or COPY all fields from one lookup to another lookup.

COPYIN works in conjunction with the LOOKUP command, to copy all fields in a looked-up record to the current record.

 

Restrictions:

COPY and COPYIN are not available on Automatic processing tables.

 

Examples:

Then: lookup arch = oldinvoices r=free -e
       Then: copy arch ; write arch ; delete ; end

The processing above gets a free record in the archive file, copies the current record to the free record in the other file, writes the other file (just for good measure, really not needed), then deletes the current record from the current file. (The DELETE command is really only executed after the END statement of a processing table is executed, but it certainly does happen. This record will now only be found in the "oldinvoices" file.)