Getting the most out of an .ini file

(imported topic written by arwhite91)

A large portion of our environment is loaded with .ini files that contain configuration settings. I’ve been writing analyses to pull back the value of certain keys within these files. In most cases I can get way with only pulling a specific key, but I’m running into trouble when I’m trying to pull back anything other than a specific key from a specific section.

Here’s a sample of data from an .ini file.

[1]

NODISC=Y

NOEMPLOYEEDISC=Y

NOFBDISC=N

NOTAX1=Y

NOTAX2=N

The desired end result is to pull back the name of any key that =Y, but I haven’t been able to find relevance to even pull the name of the key. It seems like I should be able to ask for {keys of section “1” of file “c:\file.ini” but ‘keys of is not defined.’ Is it possible to get this data, or am I barking up the wrong tree? I could say all text prior to the first = of lines that contains =Y, but I eventually need to be able to tie it back to the section it originated from as well.

(imported comment written by Jim23)

What about getting the section names of the file and the corresponding lines that contain “=Y” such as:

(lines whose (it contains “=Y” or (it starts with “”)) of file “c:\test.ini”)

or

(if (it contains “=Y”) then (preceding text of first “=” of it) else (it)) of (lines whose (it contains “=Y” or (it starts with “”)) of file “c:\test.ini”)

or to bring back the section and values back on one section per line:

substrings separated by “:-:” of concatenation of (if (it contains “=Y”) then ("," & (preceding text of first “=” of it)) else (":-:" & (it))) of (lines whose (it contains “=Y” or (it starts with “”)) of file “c:\test.ini”)

Hope this helps.

(imported comment written by arwhite91)

Thanks for the reply Jim. It looks like the third entry you posted will do the trick. Actually, that may be even better than what we had in mind initially.