Instr(). Please help

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
oldbrother
Posts: 273
Joined: 23 Oct 2013, 05:08

Instr(). Please help

Post by oldbrother » 29 Nov 2021, 13:42

The first Pos is supposed to be 7, but I always get 4. Why? StartingPOS seems not working.

Code: Select all


Txt := "123.123456"
Pos := InStr(Txt, "." , false , -1)
msgbox %Pos%  ; returns 4

Pos := InStr(Txt, "." , false , 1)
msgbox %Pos%  ; returns 4 too. 


User avatar
mikeyww
Posts: 27121
Joined: 09 Sep 2014, 18:38

Re: Instr(). Please help

Post by mikeyww » 29 Nov 2021, 13:48

StartingPos reflects the number of places to ignore.
Regardless of the value of StartingPos, the return value is always relative to the first character of Haystack.

User avatar
oldbrother
Posts: 273
Joined: 23 Oct 2013, 05:08

Re: Instr(). Please help

Post by oldbrother » 29 Nov 2021, 13:56

Hi mikeyww,

Thank you very much for your quick reply. I didn't understand it correctly. :headwall: :headwall: :headwall:

Post Reply

Return to “Ask for Help (v1)”