IniRead, Loop, and IfInstring help please Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
kunkel321
Posts: 1101
Joined: 30 Nov 2015, 21:19

IniRead, Loop, and IfInstring help please

22 Oct 2017, 14:55

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?
ste(phen|ve) kunkel
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

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

22 Oct 2017, 15:17

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.
User avatar
kunkel321
Posts: 1101
Joined: 30 Nov 2015, 21:19

Re: IniRead, Loop, and IfInstring help please

22 Oct 2017, 18:22

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:
ste(phen|ve) kunkel

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], cinematic6436, nacken012, UncouthGoose and 121 guests