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 6) - Replace hit string

&pagelevel(3)&pagelevel

If a hit is found then this format of the @ON statement replaces the hit string with a specified string.

Operation

Operands

F mode, L mode

@ON

{ lines | svars }  [,...] [:cols[:] ] C HANGE [ A LL] [ F ] [ R ] [ P ATTERN]

search [,int] [TO] string [V]

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

All the hit strings in a line are replaced by the specified string. If ALL is not
specified then only the first hit string is replaced.

F

In each specified line range, strings are only replaced in the first hit line. If
F is not specified then the replacement is made 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.

string

String that is to be replaced by 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 EDT5453 is output.

V

The number of hit lines is stored in the integer variable #I2 and the total
number of hits is stored in the integer variable #I3. The count is performed
irrespective of whether any replacement is performed or not (due to
excessive length). The V operand only has an effect if the ALL operand is
also specified. If V is not specified then the integer variables #I2 and #I3
remain unchanged.

If the replacement would cause a record to exceed the maximum record length of 32768 characters then no replacement is made, message EDT1937 is output and processing 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

The first @ON searches for the third occurrence of the character I in line 2. This I is then to be replaced by the string present in columns 19 to 21 of line 1, i.e. STU.

The second @ON replaces the first occurrence of the string IS in line 2 with an empty string, i.e. it is deleted (alternative to @ON format 9).