next up previous contents index
Next: Character Expressions Up: Character Substrings Previous: Character Substrings

Substring Rules

The parentheses denoting a substring must contain a colon: there may be an integer expression on either side of the colon. The first expression denotes the initial character position, the second one the last character position. Both values must be within the range 1 to LEN, where LEN is the length of the parent string, and the length of the resulting substring must not be less than one.

Although the colon must always be present, the two integer expressions are optional. The default value for the first one is one, the default for the second is the position of the last character of the parent string. Thus, staying with the last example: METAL(:2) has the value 'CA' while METAL(7:) has the value 'M' with three blanks.

With array elements the substring expression follows the sub-script expression, for example:

 
      CHARACTER PLAY(30)*80 
      PLAY(10) = 'AS YOU LIKE IT'
Then the substring PLAY(10)(4:11) has the value 'YOU LIKE'. Substrings can be used in expressions anywhere except in the definition of a statement function; they can also be used on the left-hand side of an assignment statement, and can be also be defined by input/output statements.



Mario Storti
Wed Nov 4 19:32:56 ART 1998