Copying File Items

The COPY processor can be used to copy:

In addition, the COPY command can be used to display the contents of one or more items on the terminal screen or printer. The COPY processor is also invoked by the CT Proc, which is used to copy the contents of an item to the terminal screen or printer.

A copy operation involves a source and a destination. The COPY processor requires that you specify the source on the command line and then prompts you for the destination.

Format

COPY [DICT] [dict-name,] filename item-list  [(options)]

Parameter(s)

filename

Source file containing the items specified in the item-list.

See the table below for a list of valid parenthetical options. The COPY processor displays the prompt TO: at which you enter the destination.

Format

TO: [[([DICT] [dict-name,] filename [)]]item-list]

If none of the above parameters are specified, pressing ENTER causes the source items to be displayed on the terminal screen. If only an item-list is specified, then the source file and the destination file are the same. Items are copied to the same file, using the item-IDs specified in the item list. The following example creates a duplicate of the item LETTER-JOHN in the file DOCUMENTS; the duplicate has the item-ID LETTER-JAMES.

>COPY DOCUMENTS LETTER-JOHN

TO :LETTER-JAMES

     1 LETTER-JOHN TO LETTER-JAMES

 

1 ITEMS COPIED

Following the copy operation, the DOCUMENTS file contains both LETTER-JOHN and LETTER-JAMES items.

Options

Function

Modifies 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.)

Modifies a file copy operation:

D

Deletes the source item after copying it.

I

Does not list item-IDs as it copies them.

N

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

O

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

Modifies operation 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.

The following rules apply:

The following example copies two items from the file ORDERS to the file ORDERS,PAID:

>COPY ORDERS 10123  10124

TO :(ORDERS,PAID)

       1 10123

       2 10124

 

  2 ITEMS COPIED

After the copy operation, both files have items 10123 and 10124. On a file copy, the item-ID of each item copied is displayed. (The I option suppresses the display of item-IDs.)

During a file copy operation, the source file item list can be specified by an asterisk (*), indicating all items are to be copied to the destination file. If the source is a dictionary file, all items except D-pointers will be copied.

If the item-ID already exists in the destination file, the following message displays:

[ 415 ] 'item' exists on file.

 

0 ITEMS COPIED

Options include:

O

Allows overwriting items specified on the destination item list.

N

Specifies that a file copy operation should succeed only if the item already exists in the destination file and ensures that new items will not be created in the destination file.

Used with the O option, the N option restricts the operation to overwriting existing items

D

Used on a file copy operation to delete the source file item once it has been copied to the destination file.

In the following example, item 10103 is copied to the ORDERS,PAID file, then deleted from the ORDERS file.

>COPY ORDERS '10103' (D)

TO :(ORDERS,PAID)

       1 10103

  1 ITEMS COPIED

See Also

Overview of File Management Commands

File Name Syntax

Item Lists

Creating Files

Creating mvBASIC Files

Copying a File

Clearing a File

Deleting Files

Editing Items

Deleting Items