Your Browser is not longer supported

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

{{viewport.spaceProperty.prod}}

@ON (format 7) - Replace or insert before or after the hit string

&pagelevel(3)&pagelevel

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]
search [,int] { CHANGE | INSERT } { PREFIX | SUFFIX } string

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
performed.

cols

Contiguous column range to which the search is to be limited.

If the range specification contains only a single column specification, this
indicates the range from the specified column through to the end of the line.
If the first column specification is greater than the line length then the line or
string variable is ignored.

If no column range is specified then the column range specified with
@SEARCH-OPTION is used.

ALL

In the case of a text insertion operation, EDT inserts the string string
before or after all the hit strings in a line. To identify any further hits, the
search continues after the inserted text in the case of a left-to-right search
and before the inserted text in the case of a right-to-left search.

In the case of a text replacement operation, EDT replaces the line content
with the string string before or after all the hit strings in a line. To identify
any further hits, the search is continued before or after the replaced text.

If, in the case of a left-to-right search, the text is replaced after a hit string
then the specification ALL is of no significance. The same applies if text is
replaced before a hit string during a right-to-left search.

If ALL is not specified then text is only inserted or replaced before or after
the first hit string in a line.

F

In each specified line range, text is only replaced or inserted in the first hit
line. If F is not specified then the replacement or insertion is performed in
every hit line of every specified line range.

R

The lines are searched through from right to left. If R is not specified then
they are searched through from left to right.

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
section “Searching with @ON”). It is not permissible to specify
an empty string.

int

Only the intth occurrence of the search term in a line is considered to
represent the first hit. Values between 1 and 32768 are permitted for int.
The default value for int is 1 byte.

CHANGE

The text located before or after the hit string up to the start or end of the
record respectively is replaced by the string specified with string.

INSERT

PREFIX

The string specified with string is inserted in front of or after the hit string.

The string specified with string replaces the line content before the hit
string or is inserted in front of the hit string.

SUFFIX

The string specified with string replaces the line content after the hit string
or is inserted behind the hit string.

string

String which is to replace the text before or after the hit string or which is to
be inserted before or after the hit string. It is also permissible to specify an
empty string.

The string is converted into the character set used by the work file or string
variable. If the string contains characters which cannot be displayed in the
target character set then these characters are replaced by a substitute
character provided that such a character has been specified (see @PAR
SUBSTITUTION-CHARACTER); otherwise, the @ON statement is rejected
and error message EDT5493 is output.

The string string should be separated from the operands PREFIX or
SUFFIX by a blank.

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 ####.