digitalexpl0it Posted January 20, 2015 Share Posted January 20, 2015 (edited) Hello I am trying to pull everything from a section in a ini file but need to batch it by each 4 lines then move to the next four lines in the section my message box shows me the correct information but when it loops I get an error at $WorkingDir = $aArray[$iii][1]. So the idea is to have many entries under the [shortcuts] section without any limits. ; Read the INI section. This will return a 2 dimensional array. Local $aArray = IniReadSection($ssFilePath, "Shorcuts") If Not @error Then for $i = 1 to $aArray[0][0] ; Set new timer $ii = $i $iii = $ii $iiii = $iii $ProgramEXEFullPath = $aArray[$i][1] ; update Timer to pull next line in INI file $ii = $i + 1 $LNKPath = StringReplace($aArray[$ii][1],"[USERNAME]", @UserName) $LNKPath = StringReplace($LNKPath,"[PROFILEPATH]", @UserProfileDir) ; update Timer to pull next line in INI file $iii = $ii + 1 $WorkingDir = $aArray[$iii][1] ; update Timer to pull next line in INI file $iiii = $iii + 1 $Desc = $aArray[$iiii][1] ; debug msgbox msgbox(0,"INI File Varibles", $ProgramEXEFullPath & " | " & $LNKPath & " | " & $WorkingDir & " | " & $Desc) ; loop $i = $i +1 next else msgbox(0,"Ahh Snap!", "Cannot read shortcuts.ini file, possible format incorrect or file currupted.") endif here is INI file [Shorcuts] ProgramEXEFullPath=C:\Program Files (x86)\Microsoft Office\Office14\WINWORD.EXE LNKPath=C:\Users\[USERNAME]\Desktop\Word 2010.lnk WorkingDir=C:\Program Files (x86)\Microsoft Office\Office14 Desc=Microsoft Word 2010 Not sure why it errors, I am doing this using 2 lines but I cant get the erorr to stop using 4, any help is greatly appreciated. Edited January 20, 2015 by digitalexpl0it Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 20, 2015 Moderators Share Posted January 20, 2015 (edited) For $i = enums the array already, so remove this line: $i = $i +1 Edit: And use the Step method: For $i = 1 To $Array[0][0] Step 4 ;(or 3?) Edited January 20, 2015 by SmOke_N 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...
digitalexpl0it Posted January 20, 2015 Author Share Posted January 20, 2015 For $i = enums the array already, so remove this line: $i = $i +1 Edit: And use the Step method: For $i = 1 To $Array[0][0] Step 4 ;(or 3?) Sweet that worked, didn't know about the step that makes things a lot easier. Link to comment Share on other sites More sharing options...
MikahS Posted January 20, 2015 Share Posted January 20, 2015 (edited) Your forgetting to use the "Step" to your advantage [Step <stepval>] For $i = 1 To $Array[0][0] Step 4 EDIT: To slow it seems. Edited January 20, 2015 by MikahS Snips & Scripts My Snips: graphCPUTemp ~ getENVvarsMy Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4 Feel free to use any of my code for your own use. Forum FAQ Link to comment Share on other sites More sharing options...
kylomas Posted January 20, 2015 Share Posted January 20, 2015 (edited) digitalexpl0it, If what you posted is the extent of your INI file you are overcomplicating this. Consider the following... ; Read the INI section. This will return a 2 dimensional array. local $ssFilePath = @scriptdir & '\initest.ini' Local $aArray = IniReadSection($ssFilePath, "Shortcuts") If Not @error Then $ProgramEXEFullPath = $aArray[1][1] $LNKPath = StringReplace($aArray[2][1],"[USERNAME]", @UserName) $LNKPath = StringReplace($LNKPath,"[PROFILEPATH]", @UserProfileDir) $WorkingDir = $aArray[3][1] $Desc = $aArray[4][1] consolewrite('$ProgramEXEFullPath = ' & $ProgramEXEFullPath & @CRLF & _ '$LNKPath = ' & $LNKPath & @CRLF & _ '$WorkingDir = ' & $WorkingDir & @CRLF & _ '$Desc = ' & $Desc & @CRLF ) else msgbox(0,"Ahh Snap!", "Cannot read shortcuts.ini file, possible format incorrect or file currupted.") endif kylomas edit: Incidentally, I changed "shorcuts" to shortcuts". Edited January 20, 2015 by kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill 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