Substring Referencing [ HP ALLBASE/4GL Developer Reference Manual Vol. 1 ] MPE/iX 5.0 Documentation
HP ALLBASE/4GL Developer Reference Manual Vol. 1
Substring Referencing
A substring is a portion of the contents of a field. Using a substring
reference allows you to refer to the portion of the contents of the field
that you require.
The substring reference must occur immediately after the normal field
reference (including subscripting, if applicable) but before any
qualifying information such as a screen name or file name.
You can reference a field substring by specifying the starting character
position number, a comma, and the number of characters in the substring.
You must enclose the entire reference in square brackets.
Format
data_ref[start_pos,number_of_chars]
data_ref[start_pos,number_of_chars].qualifier
Parameters
data_ref
The name of the field. You must prefix the field name with the prefix
character for the item type.
start_pos
The first character position to be included in the substring.
number_of_chars
The length, in characters, of the substring.
You can represent both the start_pos and the number_of_chars entries with
one of the following items containing the required values:
* Number (maximum 255).
* Numeric constant.
* Numeric variable or calculated item.
* Screen field reference.
* Scratch-pad field reference.
* File record field reference.
* Work area field reference.
The entries specifying the starting_position and number_of_characters for
the substring cannot contain substring or subscript references.
qualifier
You must always use a qualifier for S- (screen field), F- (file record
field), and W- (work area field) data types when you use substring
referencing. The qualifier specifies the name of the screen, file (and
record layout) or work area to which the field name belongs. You must
always use the current screen name as a qualifier for a substringed
screen field reference. You must prefix the combined item reference with
the prefix character for the item type.
Additional Information
You can refer to substrings in any alphanumeric field, but you cannot
refer to substrings in the following fields:
* Numeric communication area fields.
* A scratch-pad field containing a number.
* A numeric variable with an N or S edit code.
You can include substring references in absolute screen field references
(*Snn format) and relative screen field references. (* or *+nn or *-nn
format.)
You can also reference scratch-pad fields (that is *Pnn) by substring
provided the data in the scratch-pad field is not numeric.
You cannot use substrings with references to file record buffers (R-
references) or work area buffers (B- references).
Example 1
*[3,2]
This example references the third and fourth characters of the current
screen field. That is, the two characters from the third character in
the field.
Example 2
* DATE[1,2]
This statement references the first two characters of the communication
area field *DATE. These two characters correspond to the current year,
since *DATE holds the current date in the format YY/MM/DD.
MPE/iX 5.0 Documentation