Substrings
For Character String and Bit String variables, you can specify
that only a portion of the string (from here on known as a substring
)
is processed by a command.
There are three basic forms of substring specifications:
- single element
- varname(element-index)
- from-to notation
- varname(from-element-index:to-element-index)
- length notation
- varname(from-element-index::element count)
The definition of the first element of a string varies from language
to language. IDF lets you specify the format to be used:
- PL/I-like-style
-
- array index or substring expression is enclosed within parentheses
- first element in the string is element 1
- C-style
-
- array index or substring expression is enclosed within either square brackets ("[" and "]"), or the equivalent trigraphs ("??(" and "??)")
- first element in the string is element 0
Variables and built-in function results can be used to specify substring specifications.
Substring expressions follow any array index specifications, with a delimiting comma.
Substring ranges must normally be within the limits defined by the variable declaration. Suppress this check with the CHECK SUBSTRING OFF command.
Examples
var stuff
str addr(x'20000')->struct
var addr(12(R2))->ptr->stuff(2)
var ptr->ptr2->stuff
var ptr(3)->ptr->stuff
arr stuff(-5)
arr stuff(1:10)
arr stuff(1::25)
var var1;var2
var var1 ;ptr->stuff
var stuff(1:10) ; stuff(30:40)
var chrarray(15,1:10);chrarray(15,1::10)
var chrarray[15,0:9];chrarray[15,0::10]