Scan a string for any one of the
characters in a set of characters.
Class
Elemental function
Argument type and attributes
STRING
An INTENT(IN) character.
SET
An INTENT(IN) character with the same kind type
parameter as STRING.
BACK (optional)
An INTENT(IN) logical.
KIND (optional)
An INTENT(IN) integer. The actual argument corresponding
to KIND must be a constant expression.
Result type and attributes
An integer.
If KIND is present,
the KIND type parameter is that specified
by the value of KIND; otherwise, the KIND type
parameter is that of default integer type.
Result value
Case (i): If BACK is absent or is present with the value .FALSE. and
if STRING contains at least one character that is in SET, the value
of the result is the position of the leftmost character of STRING
that is in SET.
Case (ii): If BACK is present with the value .TRUE. and
if STRING contains at least one character that is in SET, the value
of the result is the position of the rightmost character of STRING
that is in SET.
Case (iii): The value of the result is zero if no character of
STRING is in SET or if the length of STRING or SET is zero.
Examples
Case (i): SCAN ('FORTRAN', 'TR') has the value 3.
Case (ii): SCAN ('FORTRAN', 'TR', BACK = .TRUE.) has
the value 5.
Case (iii): SCAN ('FORTRAN', 'BCD') has the value 0.