The syntax of the index statement

  1. INDEX ( string(i:k+1), ’ ', .true. )
  2. print*, index(bstring,astring,.true.)

Wanting to know what “.true.” does in 1.
I tried 2. and “.true.” had no effect

Could someone please explain?

See Basic procedures for manipulating character variables — Fortran Programming Language

result = index( string, substring [,back] [,kind] )

  • back
    If the back argument is present and true, the return value is the start of the rightmost occurrence rather than the leftmost.

If there is zero or one occurrence, you should therefore have no difference in the result.

Re: back is true: Thank you!

1 Like