Previous Topic: &REMSTR

Next Topic: &SETLENG


&SELSTR

The &SELSTR built-in function is used to split a section of data into two parts and assign the first part of the data to a target variable. The location at which the data is split is determined by the specification of a single character, which acts as a delimiter for the split operation. The only functional difference with an &CONTROL DBCS, DBCSN or DBCSP option in effect, is that the designated split character is a single byte character or a double byte character. With the &CONTROL NODBCS option in effect, only a single byte character is specified.

If the designated split character is a single byte character, the split can only occur where the character exists in a single byte section of the data. If the designated split character is a double byte character, the shift out and shift in characters are removed from the character, and the split can only occur where the split character is found in a double byte section of the data.

If the split occurs in a double byte section of data, a shift in is added to the end of the resultant data, if required, to preserve the integrity of the DBCS string.

Examples: &SELSTR

&CONTROL NODBCS 
&A = &SELSTR (C) ABCDEF

results in

&A = AB
&CONTROL DBCS
&A = &SELSTR (C) ABCDEF

results in

&A = AB

The &CONTROL NODBCS operation is identical to the &CONTROL DBCS operation.

&CONTROL NODBCS
&A = &SELSTR (<.D>) ABC<.C.D.E>

This operation results in a syntax error, because a double byte character can only be specified if an &CONTROL DBCS, DBCSN or DBCSP option is in effect.

&CONTROL DBCS
&A = &SELSTR (<.D>) ABC<.C.D.E>

results in

&A = ABC<.C>

Note: A shift in has been added after the double byte character .C to maintain integrity of the DBCS string.