Progress
Language Reference
OVERLAY Statement
Overlays a character expression in a field or variable starting at a given position, and optionally for a given length.
SYNTAX
target
The name of the character field or variable that you want to overlay an expression.
position
An integer expression that indicates the first character position in target where you want to store expression. The value of position must be positive. If position is longer than target, Progress pads target with blanks to match position.
length
An integer expression that indicates the number of positions you want to allocate for the storage of expression. The expression is truncated or padded with blanks to match length. If you do not use the length argument or specify -1 as the length, OVERLAY uses the entire expression.
type
A character expression that directs Progress to interpret the specified position and length values as character units, bytes, or columns. A double-byte character registers as one character unit. By default, Progress interprets the specified position and length 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, Progress validates the type specification at compile time. If you specify the type as a non-constant expression, Progress validates the type specification at run time.
expression
An expression that results in an integer value, constant, field name, variable name, or expression that results in a character string that you want to overlay on target. If you specify length, the expression is truncated or padded with blanks to match length.
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 OVERLAY statement is not equivalent to the SUBSTRING statement. When you use the OVERLAY statement, a specified number of byte or character units within the target string are overlaid with the same number of units from an expression. Therefore, the length of the target string does not change. The SUBSTRING statement replaces a specified number of units within the target string with the entire value of an expression. This may change the length of the target string.
- 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
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |