FNLMath : Utilities : IIDEX
IIDEX
This funcion determines the position in a string at which a given character sequence begins without regard to case.
Function Return Value
IIDEX — Position in CHRSTR where KEY begins. (Output)
If KEY occurs more than once in CHRSTR, the starting position of the first occurrence is returned. If KEY does not occur in CHRSTR, then IIDEX returns a zero.
Required Arguments
CHRSTR — Character string to be searched. (Input)
KEY — Character string that contains the key sequence. (Input)
FORTRAN 90 Interface
Generic: IIDEX (CHRSTR, KEY)
Specific: The specific interface name is IIDEX.
FORTRAN 77 Interface
Single: IIDEX (CHRSTR, KEY)
Description
Routine IIDEX searches for a key string in a given string and returns the index of the starting element at which the key character string begins. It returns 0 if there is no match. The comparison is case insensitive. For a case-sensitive version, use the FORTRAN 77 intrinsic function INDEX.
1. If the length of KEY is greater than the length CHRSTR, IIDEX returns a zero.
Example
This example locates a key string.

USE IIDEX_INT
USE UMACH_INT

IMPLICIT NONE
INTEGER NOUT
CHARACTER KEY*5, STRING*10
! Get output unit number
CALL UMACH (2, NOUT)
! Locate KEY in STRING
STRING = 'a1b2c3d4e5'
KEY = 'C3d4E'
WRITE (NOUT,99999) STRING, KEY, IIDEX(STRING,KEY)
!
KEY = 'F'
WRITE (NOUT,99999) STRING, KEY, IIDEX(STRING,KEY)
!
99999 FORMAT (' For STRING = ', A10, ' and KEY = ', A5, ' IIDEX = ', I2, &
/)
END
Output

For STRING = a1b2c3d4e5 and KEY = C3d4E IIDEX = 5

For STRING = a1b2c3d4e5 and KEY = F IIDEX = 0