COPY
Copies items from a file/data section to:
- Another file with the same item-ids.
- Another file with different item-ids.
- The same file with different item-ids.
- Another data section of the same file.
- A screen terminal.
- A printer.
Command class
TCL-II command.
Syntax
COPY file-specifier1 {item-list}
{(options}
TO:{(file-specifier2} {item-list}
Syntax elements
file-specifier1 The name of the file containing items to be copied.
file-specifier2 The name of file copy to (omit both parenthesis and name to copy to same file).
item-list One or more item-ids separated by spaces.
In the COPY command item-list can be an asterisk (*) to specify all items, or it can be an implicit list created by a SELECT command or by a list processing command. If item-list is omitted, you are prompted for an item list (this behaviour can be changed by setting the DEFAULT.TO.ALL environment option).
Note
If you do not specify any options but only press Return at the TO:
prompt, the file is displayed on the terminal.
Options
A Formats assembly language source items in MLIST format (a command provided with the assembler). Must be used with the P or T option.
D Deletes items from source file, after they are copied to the destination file.
F Outputs a new page before each item. Must be used with the P or T option.
I Lists destination item-ids as they are copied.
L Suppresses line numbers when used with the T or P option.
N Suppresses automatic paging when used with the T option.
O Overwrites destination file items with source file items if item-ids are the same. This option cannot be used with the T or P option.
P Sends output to the printer.
S Suppresses printing of the message, [415] 'item-id' EXISTS ON FILE
.
T Copies items to the terminal.
X Specifies a hexadecimal dump to the terminal or printer when used with the T or P option, respectively.
Note
If either the T or P option is used the TO:
destination prompt is superfluous and is automatically suppressed.
Copying items within the same file
To copy items to the same file, type only the destination item-ids without the open parenthesis at the TO: prompt.
Multiple item-ids can be copied in one operation. The item-ids of items to be copied are typed at the prompt in sequence, separated by spaces. If required the same item-id can be repeated within the line. A different number of items in the source list from the destination list may be specified. If the source list is shorter than the destination list, the COPY process terminates as soon as the source list is exhausted. If the source list is longer than the destination list, the rest of the items in the source list are copied to their same item-ids.
Caution
Exercise care when specifying the order of items in the source and destination lists, so as not to copy data to the wrong destination items.
All source items must exist when you copy multiple items. If an item you are copying is not on file, the message 'item-id' NOT ON FILE
is displayed and no operation is executed.
Copying Items to another file
The destination file must exist. If you wish to copy to a new file, you must create the file first using the CREATE-FILE command before initiating the COPY process.
To copy items to another file, type an open parenthesis, the destination file-name, an optional item-list and press return.
If you omit the open parenthesis, the COPY processor treats the destination file-name as a new item within the same file.
If you do not specify the destination item-ids, the COPY command uses the source item-list.
Copying file dictionary items
You can use the COPY command to copy any item that resides within the dictionary of a file except data level descriptors (D-pointers).
This restriction is enforced by Reality and is necessary to prevent the occurrence of multiple pointers that point to the same file area and subsequently result in corruption to the data stored there.
If you want the destination to be the dictionary of a file, include the word DICT after the open parenthesis and before the file-name.
To copy both the dictionary and data sections(s) to a new file, you must execute the COPY command once for the file dictionary and once for each data section you want to copy.
Copying to or from another account
You can also make copies from one account to another by specifying QFILE as either the source or destination file-name. When you want to specify QFILE as the destination file, remember to precede QFILE with an open parenthesis.
Note
To use QFILE as either the source file or the destination file you must first use the SET-FILE command to define QFILE.
Examples
To copy items from a file to the printer.
:
COPY BP B1 B2 (P
To copy item ITEM.A to a new item in the same file called ITEM.B. Note that the open parenthesis is not used.
:
COPY THIS.FILE ITEM.ATO:
ITEM.B1 items copied
To copy the item COST in the dictionary file called SAMPLE to a new item called WORTH within the same dictionary. Two copies of the same item now exist within the SAMPLE dictionary, one called COST and one called WORTH.
:
COPY DICT SAMPLE COSTTO:
WORTH1 items copied
To copy the item COST in the SAMPLE file to the item called WORTH. The item COST is then deleted, so only one copy of the item remains.
:
COPY SAMPLE COST (DTO:
WORTH1 items copied
To copy the items RED, WHITE and BLUE to the items GREEN, YELLOW and BROWN in the file COLOURS. If GREEN, YELLOW and BROWN already exist, they are overwritten, and items RED, WHITE and BLUE are deleted after the copy.
:
COPY COLOURS RED WHITE BLUE (D,OTO:
GREEN YELLOW BROWN3 items copied
To copy an item that resides in a file in another account to a new or different item in that same file. First use SET-FILE to define QFILE and then type:
:
COPY QFILE SOME.ITEMTO:
ITEM.C
To copy an item from a file in your account to a new or different item in another file (in either your account or another account). First use SET-FILE to define QFILE and then enter:
:
COPY THIS.FILE ITEM.ATO:
(QFILE ITEM.B
From your own account, copy an item from a file in another account to another item in that same file and account. First use SET-FILE to define QFILE and then type:
:
COPY QFILE SOME.ITEMTO:
ANOTHER.ITEM