Oooh, now that I'm thinking question three through better, I'd recommend doing a Parse Loop *that contains RegExMatch()* (or IfInString()) so that each line is isolated by A_LoopField per the Parsing Loop. If you need the first result only, then you can break upon finding it.
Code: Select all
;Haystack = Company
;Needle = Partial company name
Needle := "Brian" ; full name is Brian Johnson
IniRead, Haystack, Reopened_Claims.ini
Loop, Parse, Haystack, `n, `r ; does it work well as a CSV in IniFiles? Never noticed.
match:=A_LoopField ; you could use match.=A_LoopField "|" to get a pipe-separated list of all matches, be sure to include [c]match:=""[/c] before the loop so that you don't append to an old list if you did that
Break ; remove if you wanted to get the list of all matches
MsgBox % Needle "`n`n" match
Your needle, if you only want to match the start of the company name, your Needle could include the ^
anchor for RegEx
to tell it to match only at the start of the line.
I don't have a sample Ini to make sure that works, but then if you need to get just the section name, using something like:
Code: Select all
StringSplit, matchS, match, =
key:=matchS1 ; value:=matchS2 if you needed value
And then you could keep a running list of the key as list.=key "|"
if you wanted multiple matches for applicable Section Names.
As for the first question, I don't know your best method on that. You'd need to search in some capacity to see if all the remaining sections are Closed. Or, you can just make sure to delete all claims that are closed instead of marking them as closed in the Ini - so take care of it one at a time as you close up the claim. You'd still need to then check periodically if Section returns no Key-Value pairs on an IniRead attempt though...
As for the second question, if you can end up getting the date to the start of your list, possibly in the YYYYMMDD24HHMISS format then a sort would be possible there. Otherwise, you get into a data structure that I don't recall I've ever solved - maintaining an array or two "paired" arrays where one could be sorted and keep the order of the second. Someone might have such a sorting function for an array made. I'm kind of thinking, although it might be far from optimal, of making an array, then doing a For loop to run through the values and Pop() the array element into a new array using PushAt() to get the order somehow. Sounds like a right mess to be honest and even I don't want to sit down and work on it. Hopefully a better idea dawns on you or someone comes by with one.