Substrings (parts of cvars)

<< Click to Display Table of Contents >>

Navigation:  User guide > Variables >

Substrings (parts of cvars)

The term substring represents an expression in parentheses denoting a part of a cvar, and takes one of the following forms:

(x1:x2)

(x1:)

(:x2)

where x1 and x2 are either numbers or ivars. X1 specifies the starting point of the substring within the cvar: if it is omitted 1 is assumed. X2 specifies the end character: if it is omitted the last character is assumed.

Examples of substring usage:

if $cvar(2:5).eq.'ABCD', goto @10,

dc $c2 (4:)=' ',

ds $s1 = $c2($i1:$i2)/'12', $cx(1:$ix)/' ',

Note that if the text being compared, tested or assigned is shorter than the substring specified, the string is padded out with blanks to the required length. If it is longer, excess characters are discarded (without warning). If a substring specification containing an ivar refers, when evaluated, to a character outside the range of the cvar, the first or last character in the cvar is substituted as appropriate.

See recommended RCP SHORTCHARTEST.