FORTRAN Reference Manual
Intrinsic Functions
FORTRAN Reference Manual—528615-001
8-18
INDEX Function
Example of the ICHAR Function
The following program stores the number 35 in I and J.
CHARACTER name
name = '#'
i = ICHAR (name)
j = ICHAR ('#')
PRINT *, i, j
END
INDEX Function
The INDEX function returns an integer that points to the first character of a substring 
relative to the string that contains it.
The table below shows the argument and function type for the INDEX generic function 
and its associated specific functions.
string
is a character expression whose value is to be searched.
sub
is a character expression whose value is the substring to be found within string.
Considerations
•
INDEX returns the starting position of the first occurrence of sub in string.
•
INDEX returns a value of 0 if sub does not occur in string or if the length of sub 
exceeds that of string.
•
Blank positions in character string values are significant. For example,
CHARACTER * 15 password, try
password = 'impassable'
try = 'able'
n = INDEX (password, try)
Syntax Argument Type Function Type
INDEX (string, sub) Character Integer
INDEX4 (string, sub) Character Integer*4
INDEX8 (string, sub) Character Integer*8










