Colcopy Command [COL]
Copies one or more columns to a different location on the same line.
COLCOPY source [ /source2 ] destination1 [ /destination2 ] [ rangelist ]
(Q=no display, J=verify, T=CobX Tag)
(Default: rangelist = *)
Colcopy copies text in columns specified by source1 and source2 to the destination columns specified by destination1 and destination2 in the lines of rangelist. Even though Colcopy can modify multiple lines using a rangelist, it really operates on one line at a time. You can not copy columns from one line to another.
Source and destination columns always represent the original location. All changes are based on that assumption.
If source1 only is specified, Qedit copies just that column (length of 1). If destination1 only is specified, the source columns are inserted at that location. If you wish to replace a single column, enter a destination range where destination1 and Destination2 are the same e.g. Colcopy 1 10/10
.
/list 1
1 abcdefghijklmnopqrstuvwxyz
/colcopy 1 10 { insert column 1 at column 10 }
1 abcdefghiajklmnopqrstuvwxyz
1 line changed
/colcopy 1/5 10 { insert columns 1/5 at column 10 }
1 abcdefghiabcdejklmnopqrstuvwxyz
1 line changed
If destination1 and destination2 are specified, text in these columns is replaced by the source text. If the source text is narrower or wider, the line is shortened or expanded as needed.
/colcopy 1 10/15 { copy column 1 to columns 10/15 }
1 abcdefghiapqrstuvwxyz
1 line changed
/colcopy 1/5 10/11 { copy columns 1/5 to 10/11. Line expands. }
1 abcdefghiabcdelmnopqrstuvwxyz
1 line changed
/colcopy 1/5 10/20 { copy columns 1/5 to 10/20. Line shortens. }
1 abcdefghiabcdeuvwxyz
1 line changed
Trailing Spaces
Trailing spaces on the line are not significant. This means that a line can expand until a non-space character reaches the current right margin (Set Right). However, trailing spaces from the source text are significant and are copied in the operation. If the line can not be expanded further, Qedit displays a warning message and allows the user to modify it.
/list 2
2 abcd efghiabcdeuvwxyz
/colcopy 1/8 20 { insert columns 1/8 at 20 }
1 abcd efghiabcdeabcd uvwxyz
1 line changed
/Set right 30
/colcopy 1/5 30 { insert columns 1/5 at 30 }
Warning: Source columns could not be inserted. Please modify. (Warning 2)
1 abcd efghiabcdeabcd uvwxyz
1 line modified
Overlapping Columns
When source and destination columns do not overlap, the results are straightforward. If source and destination columns overlap partially or completely, the results might not be as expected. Keep in mind that:
- source and destination columns are always based on the original line
- the destination columns are removed
- the source columns are put in their place
Approving Each Changed Line
Use COLJ to give yourself approval over each change before it is updated. With COLJ, Qedit displays the line as it would be and asks you for a Yes, No, or Modify answer.
CobX Tags
Cobol tags are short strings stored in columns 73 to 80 of CobX source files. The Cobol tag value is defined using the Set X command. Once enabled, updated lines and added lines are automatically updated with the tag. They can also be modified manually with custom tag values.
In its regular form, the Colcopy command affects only the text area in columns 7 to 72. If you wish to make changes to Cobol tags, use the T
suffix. You can think of it as the Tag
option. This option operates only on the tag area itself, columns 73 to 80.
/ColT 73/74 79/80 all { copies content of columns 73 and 74 }
{ into columns 79/80 }
/ColT 73/74 75 all { inserts content of columns 73 and 74 }
{ in column 75. Columns 76-80 are shifted. }
To to this, the Tag
option temporarily changes the margins to (73/80)
. Qedit displays a warning every time this option is used. Because the margin values have changed, explicit column range in the source and destination columns can only be between 73 and 80.
/ColT 23/24 79/80 all
Warning: ColcopyT: editing the Cobol tag area only (73-80).
Error: The Sourcestart column (23) is not between 73 and 80
/ColT 73/74 79/80 10
Warning: ColcopyT: editing the Cobol tag area only (73-80).
10 ME0307ME
1 line changed
Because the margins have been changed, Qedit displays text in the tag area only except when the Justify option is used. In this case, Qedit prompts for confirmation before making the change. It would be hard to determine if a line needs to be changed based only on the tag value. So, when the Justify option is used, Qedit displays the complete line. The user has the option to accept the changes, reject the changes or manually modify the line. If the user chooses to modify the line, only the tag is displayed.