# The syntax of the index statement

**URL:** <https://fortran-lang.discourse.group/t/the-syntax-of-the-index-statement/5873>\
**Category:** Uncategorized\
**Created:** [May 28, 2023, 10:40am UTC](https://fortran-lang.discourse.group/t/the-syntax-of-the-index-statement/5873 "2023-05-28T10:40:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Patrick](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/patrick/32/3170_2.png) [@Patrick](https://fortran-lang.discourse.group/u/Patrick)\
**Post date:** [May 28, 2023, 10:40am UTC](https://fortran-lang.discourse.group/t/the-syntax-of-the-index-statement/5873/1 "2023-05-28T10:40:17Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![vmagnin](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/vmagnin/32/28_2.png) [@vmagnin](https://fortran-lang.discourse.group/u/vmagnin)\
**Post date:** [May 28, 2023, 10:50am UTC](https://fortran-lang.discourse.group/t/the-syntax-of-the-index-statement/5873/2 "2023-05-28T10:50:34Z")

</div>

See [Basic procedures for manipulating character variables — Fortran Programming Language](https://fortran-lang.org/en/learn/intrinsics/character/#index)

> 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.

---

<div class="post-metadata">

**Author:** ![Patrick](https://yyz2.discourse-cdn.com/free1/user_avatar/fortran-lang.discourse.group/patrick/32/3170_2.png) [@Patrick](https://fortran-lang.discourse.group/u/Patrick)\
**Post date:** [May 28, 2023, 11:17am UTC](https://fortran-lang.discourse.group/t/the-syntax-of-the-index-statement/5873/3 "2023-05-28T11:17:36Z")

</div>

Re: back is true: Thank you!
