This format of the @ON statement can be used to insert or replace text before or after a hit string in work file lines or string variables.
Operation | Operands | F mode, L mode |
@ON | { lines | svars } [,...] [:cols[:] ] FIND [ALL] [F] [R] [PATTERN] |
lines svars | One or more line ranges in which the search is to be performed. One or more ranges of string variables in which the search is to be |
cols | Contiguous column range to which the search is to be limited. If the range specification contains only a single column specification, this If no column range is specified then the column range specified with |
ALL | In the case of a text insertion operation, EDT inserts the string In the case of a text replacement operation, EDT replaces the line content If, in the case of a left-to-right search, the text is replaced after a hit string If |
F | In each specified line range, text is only replaced or inserted in the first hit |
R | The lines are searched through from right to left. If |
PATTERN search | The wildcards present in the search term are interpreted. Search term that is to be searched for in the search range (for details, see |
int | Only the |
CHANGE | The text located before or after the hit string up to the start or end of the |
INSERT PREFIX | The string specified with The string specified with |
SUFFIX | The string specified with |
string | String which is to replace the text before or after the hit string or which is to The string is converted into the character set used by the work file or string The string |
No text is replaced or inserted if this would cause the record to exceed the maximum record length of 32768 characters. Instead, in this case, the message EDT1937
is output and execution is continued.
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.
Example 1
All shareable files under the user ID USER2
which begin with the partially qualified name XMPL
. are to be listed.
Every partially qualified name XMPL
. is to be preceded by the string @READ '$USER2..
The closing single quote is inserted after the four file names $USER2.XMPL.1 to
$USER2.XMPL.4.
The four files XMPL.1
to XMPL.4
are read in sequence into work file 1.
Example 2
The third occurrence of the string 11 (reading right to left) is to be searched for in the line range 1 to 2 and, if a hit is found, ++++
is to be inserted after it.
In line 1, the search term occurred the third time (reading from the right) in columns 17-18.
In line 2, the search term occurred for the first time in columns 24-25, for the second time in columns 22-23 and for the third time in columns 19-20. The string ++++
has been inserted after the hit.
It is now necessary to search through the entire work file as of column 4 for the third occurrence of the string 111. If a hit is found then the text that follows it is to be replaced by ####
.
The search term was not found in line 1.
In line 2, the search term occurred as a hit as of line 4 for the first time in columns 7-9, for
the second time in columns 12-14 and for the third time in columns 17-19. The remainder
of the line after the hit has been replaced by the string ####.