HLASM Language Reference
Previous topic | Next topic | Contents | Contact z/OS | Library | PDF


Substring notation

HLASM Language Reference
SC26-4940-06

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.

Table 1. Substring notation in conditional assembly instructions
  Used in   Used as   Example

Value
assigned to
SETC Symbol

SETC instruction operand

Operand
 
Part of
operand

&C1  SETC  'ABC'(1,3)
 
&C2  SETC '&C1'(1,2).'DEF'

ABC
 
ABDEF

AIF or SETB instruction operand (logical expression) Character value in comparand of character relation
    AIF   ('&STRING'(1,4) EQ 'AREA').SEQ
&B  SETB  ('&STRING'(1,4).'9' EQ 'FULL9')
---
The substring notation must be specified as follows:
'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 1024 characters. The length of the resulting substring must be in the range 0 through 1024.

The subscripts, e1 and e2, must be arithmetic expressions.

When you use subscripted variable symbols in combination with substring notation, take care to distinguish variable subscripts from substring-operation subscripts.
       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)

Go to the previous page Go to the next page




Copyright IBM Corporation 1990, 2014