COPY Command

The COPY command copies selected file items to another file, to the printer, or to the terminal. In addition, you can copy any item and store it in the same file by giving it a new item-ID. Note that COPY does not copy files; it copies items in files.

Format

COPY [DICT] filename item-list [(options)]

Parameter(s)

DICT

Specifies the file dictionary.

filename

Name of the source file containing the original item or items.

item-list

List of item-IDs you want to copy, separated by blanks. Use double quotes to enclose item-IDs that have embedded blanks. An asterisk (*) signifies all items.

options

The following options are supported. Enclose the options in a single set of parentheses and separate the options with a comma.

The options below are used when specifying the destination of the copied items:

P

Copies data to the line printer.

T

Copies data to the terminal. (You can also use the CT command to copy items to the terminal.)

The options below are used when copying items or files to other items or files:

D

Deletes the source item after copying it.

I

Does not list item-IDs after copying them.

N

Does not copy an item to the destination file unless an item with the same name already exists there.

O

Overwrites items in the destination file if they already exist there.

S

Suppresses messages.

The options below are used when copying items or files to a printer or terminal:

F

Inserts a form feed between each item.

N

Skips the automatic end-of-page wait.

S

Suppresses line numbers.

X

Displays data in hexadecimal form.

To print the copy, use the P option; to display it on the terminal screen, use the T option. If neither option is specified, the system prompts you as follows:

TO:

Press ENTER to copy the items to the screen.

Copying Items to the Same File or Another File

To copy items to the same file or to another file, respond to the destination prompt using this syntax:

Format

{item-list | ([DICT] filename) [item-list]}

Parameter(s)

DICT

Specifies a file dictionary. When copying from a dictionary, the COPY command will not copy dictionary items that have a definition code of D (File Definition items).

filename

Name of the destination file, enclosed in parentheses. This file must already exist on disk.

item-list

List of item-IDs to be assigned in sequence to the copied items. Use blanks to separate the item-IDs, and use double quotes to enclose any item-ID that has embedded blanks. If this item-list is omitted, the item-IDs in the source file are used. If you are copying items to the same file, the item-IDs cannot be the same as those for existing items, unless you are using the O option.

Copying Items to the Terminal

This example, which uses the T option, copies an item from data file PAYROLL to the terminal:

>COPY PAYROLL 404-82-9927 (T)

   

404-82-9927

001 3745

002 SMITH, JOHN

003 1234 MAIN STREET

004 DALLAS

005 TX

 

>

Copying Items Within the Same File

The following example copies the items N, O, and B in a file called INVENTORY to the existing items NEW, OLD, and BILLED in the same file:

>COPY INVENTORY N O B

TO: NEW OLD BILLED

   1 N TO NEW

   2 O TO OLD

   3 B TO BILLED

   3 ITEMS COPIED

All six items now exist on file.

If you want to delete items N, O, and B after copying them, include the D option at the end of the command line:

>COPY INVENTORY N O B (D)

TO: NEW OLD BILLED

 

   1 N TO NEW

   2 O TO OLD

   3 B TO BILLED

3 ITEMS COPIED

Now only the items NEW, OLD and BILLED exist; N, O, and B have been deleted. This is a useful way to rename items in a file.

Renaming Items

The following example renames item COST in dictionary INVENTORY and calls it PRICE:

>COPY DICT INVENTORY COST (I,D)

TO: PRICE

 

1 ITEMS COPIED

The I option suppresses the listing of the item-ID, and the D option deletes the item COST once it is copied.

Copying Items Between Files

The following example copies all items from dictionary ORDER to dictionary INVOICE:

>COPY DICT ORDER *

TO: (DICT INVOICE)

   1 ORDER#

   2 CUSTOMER

   .

   .

   .

[418]  FILE DEFINITION ITEM 'ORDER' NOT COPIED

13 ITEMS COPIED

The parentheses identify DICT INVOICE as the destination file. If the parentheses were not included, the COPY command would interpret DICT and INVOICE as item-IDs within the same file.

Copying All Items to a New File

The following example creates a new file called CUST and copies all items in CUSTOMERS to it:

>CREATE-FILE CUST 3 3

 

[417]  FILE 'CUST' CREATED; BASE = 9139, MODULO = 3

 

[417]  FILE 'CUST' CREATED; BASE = 9145, MODULO = 3

 

>COPY CUSTOMERS * (D)

TO: (CUST)

   1 BUCKLER

   2 ZURROW

   3 DANVERS

   4 ROTH

   .

   .

   .

 

58 ITEMS COPIED

The D option deletes the items from CUSTOMERS as they are copied.