Page 1 of 1

IniRead, Loop, and IfInstring help please

Posted: 22 Oct 2017, 14:55
by kunkel321
Hi All,
I have a very small amount of experience with IniRead, and even less with Loops. This is my first time using IfinString, but it seems like the following script should work.

Code: Select all

#NoEnv
#SingleInstance force
;#################################

Haystack :=  "meeting for Jon Doe in RR tomorrow."

;===========
IniRead, AllLocations, LocationsList.txt ;Gets `n-delimited list from ini file.
Loop, Parse, AllLocations, `n,`r  ; Parses list.
  {
    IfInString, Haystack, %A_LoopField%
    {
      MsgBox, Yes found %A_LoopField%
      Return
    }
    Else
    MsgBox, No, not found.
    Return
  }
In the same folder, I have a text file "LocationsList.txt" with the following (ini-formatted) content.

Code: Select all

[myLocations]
1=office
I expected it to yield a message box with "Yes found office," but instead, I get "No, not found."

Any thoughts on my error?

Re: IniRead, Loop, and IfInstring help please  Topic is solved

Posted: 22 Oct 2017, 15:17
by BoBo
You are parsing/looping through the list of detected sections (let's doubt you'll find any section names in your haystack), but didn't use those to take/read the key values from sections of the ini file.

Re: IniRead, Loop, and IfInstring help please

Posted: 22 Oct 2017, 18:22
by kunkel321
Ah yes! Thanks for the feedback. I need to have the locations listed in the [sections] not the keys. Also, I see the my Haystack didn't have "office" in it, as it was supposed to. (The version that I was experimenting with did though.) Thanks again BoBo!

Whoops nevermind the additional question! (which I just removed)
I have to get that "Else" statement out of the loop if I ever want to find anything other than the first [section]! LOL :crazy: