Purpose
Returns the starting position of
a substring within a string.
Argument type and attributes
- STRING
- An INTENT(IN) CHARACTER
- SUBSTRING
- An INTENT(IN) CHARACTER with
the same kind type parameter as STRING.
- BACK (optional)
- An INTENT(IN) LOGICAL
- KIND (optional)
- An INTENT(IN) INTEGER scalar.
The actual argument corresponding to KIND must
be a constant expression.
Result type and attributes
- It is of type 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 present with the value .FALSE.,
the result is the minimum positive value of I such that STRING (I
: I + LEN (SUBSTRING) - 1) = SUBSTRING or zero if there is no such
value. Zero is returned if LEN (STRING) < LEN (SUBSTRING). One
is returned if LEN (SUBSTRING) = 0.
- Case (ii): If BACK is present with the value .TRUE.,
the result is the maximum value of I less than or equal to LEN (STRING)
- LEN (SUBSTRING) + 1, such that STRING (I : I + LEN (SUBSTRING) -
1) = SUBSTRING or zero if there is no such value. Zero is returned
if LEN (STRING) < LEN (SUBSTRING) and LEN (STRING) + 1 is returned
if LEN (SUBSTRING) = 0.
Examples
INDEX ('FORTRAN',
'R') has the value 3.
INDEX ('FORTRAN', 'R', BACK = .TRUE.)
has the value 5.
Specific Name |
Argument Type |
Result Type |
Pass As Arg? |
INDEX |
default character |
default integer |
yes 1 |
Note: - 1 When this specific name is passed
as an argument, the procedure can only be referenced without the BACK and KIND optional
argument.
|