Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

@COPY (format 2) - Copy lines or string variables

&pagelevel(3)&pagelevel

The @COPY statement copies records from the current or another work file or the content of a string variable into the current work file.

For the sake of clarity, the line range in the source work file which contains the records that are to be copied or the range of string variables are referred to as the “source range” below. The line range in the current work file into which the records from the source work file are to be copied is referred to as the “target range”.

Operation

Operands

F mode, L mode

@COPY

{ {lines [ (procnr) ] | svars } [TO { line1 [(inc)] [:] [line2] } [,...]] } [,...]

lines

Contiguous line range that is to be copied into the current work file.
Symbolic line numbers in lines refer to the line numbers of the current
work file even if the lines are copied from another work file.

procnr

Number of the source work file from which the lines are to be copied
(0..22). If procnr is not specified then the lines are copied from the current
work file. An active work file may not be specified.
If the TO operand is not specified then procnr must not be the current work
file.

svars

Range of string variables whose contents are to be copied into the current
work file.

TO...

The operands which follow TO define the target range or ranges. If no target
range is specified then the line numbers in the source work file are taken
over into the current work file.
If the source work file is the current work file or if string variables are copied
then TO... must be specified. In these cases, if no target range is specified
then the @ COPY statement is rejected with the error message EDT3218.

line1

inc

Number of the first line in the target range.

Increment used to form the line numbers following line1. If inc is not
specified then the increment implicitly specified by line1 is used (see
section “Implicit increment assignment”).

:The operands line1 and line2 should be separated by : if inc is not specified.

line2

Specifies the largest possible line number in the target range up to which
the copying of records is permitted.

As a result, nothing is copied into lines in the current work file with line
numbers higher than line2. This also applies if it is not possible to copy all
the records in the source range to the target range.
If line2 is not specified then the @COPY statement does not define any
maximum value for the line numbers in the target range.

In the @COPY statement, it is possible to specify multiple comma-separated source ranges each of which are associated with multiple target ranges. The number of source and target ranges is only limited by the maximum permitted length of EDT statements.

If the source and target ranges overlap then the source range is copied line-by-line. This means that a record may initially be copied to a line and then be copied again from this line if the line is present in both the source and target ranges. In this way, it is possible to create multiple copies of the source range or parts of it in the target range.

Any existing lines with the same line numbers present in the work file are overwritten on the copy operation.

If a line with a number greater than the previous highest line number is created then the current line number is modified.

If the current work file is empty and has the character set *NONE then it is assigned the character set of the source work file or the first specified string variable when the copy operation is performed. If the current work file has a character set then the lines to be copied or the contents of the string variables are converted into the character set of the current work file. If characters which cannot be displayed in the work file's character set are identified then these characters are replaced by a substitute character provided that such a character has been specified (see @PAR SUBSTITUTION-CHARACTER); otherwise, the @ COPY statement is rejected and error message EDT5453 is output.

If the statement is interrupted with [K2] and the EDT session is continued with /INFORM-PROGRAM then the processing of the statement is aborted and message EDT5501 is output.

Note

Since the above syntax permits the omission of the TO operand, it is not always possible to distinguish unambiguously between the target and source ranges. In such cases, EDT interprets the ambiguous specification as a target range. Thus, for example, in the input

@COPY 2-3(1) TO 7,1(1)

the specification 1(1) is interpreted as a second target range (the 1 in parentheses is interpreted as the increment), whereas the specification 1(0) at this point would be interpreted as the next source range (the 0 cannot be an increment and is interpreted as a work file number). If, in this example, the user wants to force the specification to be interpreted as a source range, it would be possible, for example, to enter

@COPY 2-3(1) TO 7,1-1(1)

to eliminate all ambiguities.

Example 1

The three @COPY statements are intended to copy line 1 to line 7, line 2 to line 5 and line range from 1 to 3 to the line range starting at line 30.1 with the explicit increment 5.

Example 2

The @COPY statement can be used to duplicate line ranges one or more times if the send and receive areas overlap. In the example below, the first line is to be duplicated.

This statement copies the line range from line number 1 to 2 to the line range starting at line number 1.5 with the implicit increment 0.1.

In this case, EDT starts by copying line 1 to line 1.5. This line is located in the specified source range. Consequently line 1.5 is copied to line 1.6 with the implicit increment 0.1. Accordingly, line 1.6 is copied to 1.7, ... , line 1.9 to 2.0 (and the content of line 2 is overwritten) and line 2.0 is then copied to line 2.1.

The line range 3 to 5 is to be copied to the line range 4.1 to 5 with the implicit increment 0.1.

To do this, EDT first copies line 3 to line 4.1 and line 4 to line 4.2. The two newly created lines are located in the specified source range. As a result, line 4.1 is copied to line 4.3, line 4.2 to 4.4 ... , line 4.8 to 5.0. This operation overwrites the content of line 5. Lines 4.9 and 5.0 are not copied since the highest possible line number in the target range has been reached.