SUBSTRING function
Extracts a portion of a character string from a field or variable.
Syntax
source
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 four valid types: "CHARACTER," "FIXED," "COLUMN," and "RAW." The expression "CHARACTER" specifies character units. The expression "FIXED" specifies thatposition
is in character units and the length is in bytes, but directs SUBSTRING to yield only whole characters. That is, if the last byte or bytes represent part of, but not all of, a multi-byte character, these bytes are excluded. The expression "COLUMN" specifies display or print character-columns. The expression "RAW" specifies bytes. If you specify thetype
as a constant expression, ABL validates the type specification at compile time. If you specify thetype
as a non-constant expression, the AVM validates the type specification at run time.Note: Ifsource
is a LONGCHAR expression, "CHARACTER" is the only valid type and the default type.ExampleThe
r-substr.p
procedure uses the SUBSTRING function to create invoice numbers. You supply a starting invoice number. The first SUBSTRING function produces the first two characters of today’s date; the second SUBSTRING function produces the last two characters of today’s date. The procedure concatenates these four characters to a hyphen and the number you entered to produce an invoice number.
See also
OpenEdge Release 10.2B
|