|     | 
SUBSTRING statement
Inserts content from a specified expression into a field or variable, optionally replacing existing characters, bytes, or columns.
Syntax
targetpositionlength
An integer expression that indicates the number of positions you want to replace in thetarget. If you specify a length of 0, the entireexpressionis inserted at thepositionand everything else moves to the right. If you do not use thelengthargument or specify -1 as the length, SUBSTRING puts the entireexpressioninto thetarget, replacing an equal amount of thetarget.type
A character expression that directs ABL to interpret the specifiedpositionandlengthvalues as character units, bytes, or columns. A double-byte character registers as one character unit. By default, ABL interprets the specifiedpositionandlengthvalues 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 thetargetis a LONGCHAR expression, "CHARACTER" is the only valid type.expressionExamplesThe r-sub.p procedure uses the SUBSTRING statement to replace a segment of text with the expression in the SUBSTRING statement XXXXXXXXX. The procedure first displays the text you can work with in the Original Text frame. Then the procedure prompts you for the start position of the replacement and the length of the replacement. Under the WORD heading, you see the revised text.
The SUBSTRING and OVERLAY statements use the
lengthoption differently. For both, thelengthindicates how much of thetargetto replace. However, SUBSTRING always inserts the fullexpressionand never pads theexpressionto match thelength. By contrast, thelengthin OVERLAY determines how much ABL adds to thetarget, even if ABL must truncate theexpressionor pad it with spaces. The r-sub-over.p (1 of 2) procedure illustrates the differences between these two statements.
NoteSee also
|  | 
| OpenEdge Release 10.2B | 
|     |