The statement code O
copies or moves records with work file and line numbers collected in the copy buffer using C
, M
or R
onto the specified line and the subsequent line range.
Statement code | Key |
O | [DUE] or [F2] |
For the sake of simplicity; the description below refers only to copying even if the lines are deleted after the copy operation (i.e. they are moved).
If the copy buffer is empty then the statement is rejected with the message EDT5376
.
It is necessary to distinguish between two cases:
If the specified record is displayed as of column 1 in the data window then the entire content of the specified record is overwritten by the record that is to be copied.
If the specified record is displayed in the data window as of a column position greater than column 1 then the range starting at the displayed column position is overwritten with the content and to the length of the record that is to be copied. If the length of the record that is to be copied is less than the length of the record specified in
O
then the remaining parts of the record that is to be overwritten are retained. In this way it is possible to insert records in other records or append them to other records.
If more than one line is transferred for copying then they are written to the corresponding number of records which follow the specified record. If this operation goes beyond the end of the work file then new lines are created there.
When inserting or appending the copied lines, EDT assigns line numbers using the procedure “Insertion between two lines” (see section “Line number assignment”). If it is not possible to append the lines then the copy operation is not performed, the copy buffer is not deleted and the message EDT5365
is output. However, any lines that have already been overwritten remain so.
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 of the first line for copying when the copy operation is performed.
If the current work file has a character set then the lines that are to be copied are converted into this work file's character set. If characters are detected which cannot be displayed in the work file's character set then these are replaced by a substitute character if such a character has been specified (see @PAR SUBSTITUTION-CHARACTER). Otherwise, the statement code is rejected and the error message EDT5453
is output.
Note
The statement code O
is not executed until after any C
-, M
and R
statements have been processed. As a result, it is possible to specify the target location before the lines that are to be copied in a single dialog step in a work window.
Unexpected effects may occur if O
is used to copy over a line which is itself located in the range of lines that are to be moved or copied, and in particular when lines are moved with M
. For more information, see the following examples:
Example 1
Line 2.00
is to be copied to line 3.00
. This is achieved by entering statement code C
in line 2.00
, statement code O
in line 3.00
.
Line 3.00
has been overwritten with the content of line 2.00
.
Example 2
Lines 2.00
to 5.00
are collected for copying.
The lines from the copy buffer are to be copied onto line 4.00
and the following lines.
Since the copy operation has modified the content of the lines in the copy buffer itself, the above result is obtained.
Example 3
Line 2.00
is selected to be moved.
It is to overwrite line 2.00
.
Line 2.00
has been deleted because, when lines are moved, they are deleted after transfer.
Example 4
Lines 1.00
to 3.00
are selected for copying. At the same time, the statement >8
is used to move the data window 8 characters to the right.
The statement code O
copies the lines from the copy buffer over line 1 which has been moved to the right and the line which follows it. At the same time, the statement <<
is used to move back to the start of the record.
The result is that each line has been appended to itself.