gcue Posted February 17, 2008 Share Posted February 17, 2008 hello. i am trying to process an INI file that has multiple sections. within each section a list of devices with their ips. as such: [location1] printer1=29.1.12.1 computer1=292.21.21.1 [location2] printer1=292.1.12.1 server=21.1.1.1. you get the idea... heres what i have (at this point im just trying to sort out the variable part): $location = IniReadSectionNames(@ScriptDir & "\devices.ini") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $i = 1 To $location[0] $device = IniReadSection(@scriptdir & "\devices.ini", "$location[i]") For $p = 1 To $device[0][0] MsgBox(4096, "", "Location: " & $location[$i][0] & @CRLF & "Key: " & $device[$p][0] & @CRLF & "Value: " & $device[$p][1]) Next Next EndIf Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 17, 2008 Moderators Share Posted February 17, 2008 $device = IniReadSection(@scriptdir & "\devices.ini", $location) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
GEOSoft Posted February 17, 2008 Share Posted February 17, 2008 Try this. I think I fixed the errors but I'm just winging it so it's untested. $location = IniReadSectionNames(@ScriptDir & "\devices.ini") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $i = 1 To $location[0] $device = IniReadSection(@scriptdir & "\devices.ini", "$location[$i]") For $p = 1 To $device[0][0] MsgBox(4096, "", "Location: " & $location[$i] & @CRLF & "Key: " & $device[$p][0] & @CRLF & "Value: " & $device[$p][1]) Next Next EndIf George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
gcue Posted February 17, 2008 Author Share Posted February 17, 2008 thanks for the quick response. now im getting a different error: error in parsing function call not sure where thats coming from...any idea? $device = IniReadSection(@scriptdir & "\devices.ini", $location) Link to comment Share on other sites More sharing options...
gcue Posted February 17, 2008 Author Share Posted February 17, 2008 thanks for trying.. i still get the error... Try this. I think I fixed the errors but I'm just winging it so it's untested. $location = IniReadSectionNames(@ScriptDir & "\devices.ini") If @error Then MsgBox(4096, "", "Error occurred, probably no INI file.") Else For $i = 1 To $location[0] $device = IniReadSection(@scriptdir & "\devices.ini", "$location[$i]") For $p = 1 To $device[0][0] MsgBox(4096, "", "Location: " & $location[$i] & @CRLF & "Key: " & $device[$p][0] & @CRLF & "Value: " & $device[$p][1]) Next Next EndIf Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 17, 2008 Moderators Share Posted February 17, 2008 Local $location, $i, $device, $p $location = IniReadSectionNames(@ScriptDir & "\devices.ini") If IsArray($location) Then For $i = 1 To $location[0] $device = IniReadSection(@scriptdir & "\devices.ini", $location[$i]) If IsArray($device) Then For $p = 1 To $device[0][0] MsgBox(4096, "", "Location: " & $location[$i] & @CRLF & "Key: " & $device[$p][0] & @CRLF & "Value: " & $device[$p][1]) Next Else MsgBox(16, "Error", "There was an error reading section: " & $location[$i] & @CRLF & "Section Number was: " & $i) EndIf Next Else MsgBox(16, "", "Error occurred, probably no INI file.") EndIfAlways best to error check so you can see the error for yourself. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
gcue Posted February 17, 2008 Author Share Posted February 17, 2008 brilliant!!! thank you so much!!! Local $location, $i, $device, $p $location = IniReadSectionNames(@ScriptDir & "\devices.ini") If IsArray($location) Then For $i = 1 To $location[0] $device = IniReadSection(@scriptdir & "\devices.ini", $location[$i]) If IsArray($device) Then For $p = 1 To $device[0][0] MsgBox(4096, "", "Location: " & $location[$i] & @CRLF & "Key: " & $device[$p][0] & @CRLF & "Value: " & $device[$p][1]) Next Else MsgBox(16, "Error", "There was an error reading section: " & $location[$i] & @CRLF & "Section Number was: " & $i) EndIf Next Else MsgBox(16, "", "Error occurred, probably no INI file.") EndIfAlways best to error check so you can see the error for yourself. Link to comment Share on other sites More sharing options...
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