Progress
Language Reference
SUBSTRING Statement
Replaces characters in a field or variable with an expression you specify.
SYNTAX
source
A field or variable that you want to store as expression.
position
An integer expression that indicates the position in source in which you want to start storing expression. If position is longer than source, Progress pads source with blanks to equal the length of position.
length
An integer expression that indicates the number of positions you want to replace in source. If you specify a length of 0, the expression is inserted at the position and everything else moves to the right. If you do not use the length argument or specify -1 as the length, SUBSTRING puts the entire expression into source, replacing everything in source necessary to make room for 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
A constant, field name, variable name, or expression that results in a character string whose value you want to store in source. Progress does not pad or truncate expression.
EXAMPLEThe
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.
NOTES
- When you use the SUBSTRING statement, the length of the target string may change (because the length of the expression value is not the same as the length of the substring you are replacing). By contrast, the OVERLAY statement never changes the length of the target string. The OVERLAY statement truncates or pads the expression value to make it the same length as the substring to be replaced.
- Do not split double-byte characters. This statement allows you to replace either the lead- or trail-byte of the target string when you specify "RAW" for the type parameter.
SEE ALSO
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |