OVERLAY statement
Inserts content from a specified expression into a field or variable replacing existing characters, bytes, or columns.
Syntax
target
position
length
type
A character expression that directs ABL to interpret the specifiedposition
andlength
values as character units, bytes, or columns. A double-byte character registers as one character unit. By default, ABL interprets the specifiedposition
andlength
values as character units.There are three valid types: "CHARACTER," "RAW," and "COLUMN." The expression "CHARACTER" specifies character units. The expression "RAW" specifies bytes. The expression "COLUMN" specifies display or print character-columns. If you specify the type as a constant expression, ABL validates the type specification at compile time. If you specify the type as a non-constant expression, the AVM validates the type specification at run time.Note: If thetarget
is a LONGCHAR expression, "CHARACTER" is the only valid type.
expression
ExampleThe
r-replc1.p
procedure lets you search for, and replace text strings in a paragraph in a window. When you run the procedure, you see the paragraph, which is an array with an extent of five. You also see a prompt. Enter the text string you want the system to search for, and the new text you want in its place. The procedure searches the paragraph, one line at a time, for the text you entered. The procedure uses the OVERLAY statement to replace the string of old text with the string of new text. The procedure also determines the length of the old text and the new text.
Notes
- The SUBSTRING and OVERLAY statements use the
length
option differently. For both, thelength
indicates how much of thetarget
to replace. However, SUBSTRING always inserts the fullexpression
and never pads theexpression
to match thelength
. By contrast, thelength
in OVERLAY determines how much ABL adds to thetarget
, even if ABL must truncate theexpression
or pad it with spaces. See the r-sub-over.p procedure for an illustration the differences between these two statements.- Do not split double-byte characters. This statement allows you to overlay either the lead or trail-byte of the target string when you specify "RAW" as the
type
parameter.See also
OpenEdge Release 10.2B
|