Hypertrophy Posted July 8, 2009 Posted July 8, 2009 Here's what my ini looks like key1=joe key2=bob,will key3=sam,whatever key4=doodoo how do i go through this ini and locate ONLY the values that have commas in them (meaning the values that are arrays) and doing somehing, while disregarding all the other values that do no fit the above criteria. im lost.
Crystall Posted July 8, 2009 Posted July 8, 2009 (edited) Hello. Maybe something like this: $aSection = IniReadSection("C:\PathTo\MyFile.ini", "MySection") For $i = 1 To $aSection[0][0] If StringInStr($aSection[$i][1], ",") Then MsgBox(4096, "", "Array value found! Text: " & $aSection[$i][1]) EndIf Next If you want to go through ALL sections of your INI, put the code above into another loop: $aSectionNames = IniReadSectionNames("C:\PathTo\MyFile.ini") For $x = 1 To $aSectionNames[0] $aSection = IniReadSection("C:\PathTo\MyFile.ini", $aSectionNames[$x]) For $y = 1 To $aSection[0][0] If StringInStr($aSection[$y][1], ",") Then MsgBox(4096, "", "Array value found! Text: " & $aSection[$y][1]) EndIf Next Next Edited July 8, 2009 by Crystall Hello World!
Hypertrophy Posted July 8, 2009 Author Posted July 8, 2009 (edited) Hi. Thank you this looks very good. Another question, what if I wanted to handle the values that weren't arrays? How would I structure the loop then? For example code below only handles the values in the section that are arrays. What if I also have individual values like in my first post. How would I go about handling them? $aSection = IniReadSection("C:\PathTo\MyFile.ini", "MySection") For $i = 1 To $aSection[0][0] If StringInStr($aSection[$i][1], ",") Then MsgBox(4096, "", "Array value found! Text: " & $aSection[$i][1]) EndIf Next Edited July 8, 2009 by Hypertrophy
picea892 Posted July 8, 2009 Posted July 8, 2009 I think you could just add an else statement to capture those. $aSection = IniReadSection("C:\PathTo\MyFile.ini", "MySection") For $i = 1 To $aSection[0][0] If StringInStr($aSection[$i][1], ",") Then MsgBox(4096, "", "Array value found! Text: " & $aSection[$i][1]) else MsgBox(4096, "", "Non-Array value found! Text: " & $aSection[$i][1]) EndIf Next
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now