Substring notation
The substring notation lets you refer to one or more characters within a character string. You can, therefore, either select characters from the string and use them for substitution or testing, or scan through a complete string, inspecting each character. By concatenating substrings with other substrings or character strings, you can rearrange and build your own strings.
The substring notation can be used only in conditional assembly instructions. Table 1 shows how to use the substring notation.
Used in | Used as | Example |
Value
assigned to SETC Symbol |
---|---|---|---|
SETC instruction operand | Operand
Part of operand |
|
ABC
ABDEF |
AIF or SETB instruction operand (logical expression) | Character value in comparand of character relation |
|
--- |
'CHARACTER STRING'(e1,e2)
where
the CHARACTER STRING
is a character expression from
which the substring is to be extracted. The first subscript (e1)
shows the position of the first character that is to be extracted
from the character string. The second subscript (e2)
shows the number of characters to be extracted from the character
string, starting with the character indicated by the first subscript.
Thus, the second subscript specifies the length of the resulting
substring.The second subscript value of the substring notation can be specified
as an asterisk (*
), to indicate that all the characters
beginning at the position of the first expression are used. The extracted
string is equal to the length of the character expression, less the
number of characters before the starting character.
The character string must be a valid character expression with a length, n, in the range 1 through 4064 characters. The length of the resulting substring must be in the range 0 through 4064.
The subscripts, e1 and e2, must be arithmetic expressions.
LCLC &DVAR(10),&SVAR,&C(10)
&C(1) SETC '&DVAR(5)' Select 5th element of &DVAR
&C(2) SETC '&SVAR'(1,3) Select substring of &SVAR
&C(3) SETC '&DVAR(5)'(1,3) Select substring of &DVAR(5)
&C(4) SETC '&SYSLIST(1,3)'(1,3) Select substring of &SYSLIST(1,3)