Mast3rpyr0 Posted August 12, 2007 Share Posted August 12, 2007 Do i have to initialize the variable as a 2d array or something? if so then how? $INI = IniReadSectionNames(@ScriptDir & "\config.ini") For $i = 1 To Ubound($INI) Step 1 $INI2 = IniReadSection(@ScriptDir & "\config.ini", $i) Local $v = 70 _ArrayDisplay($ini2) GUICtrlCreateLabel($INI2[1][1], 20, $v) Next C:\Documents and Settings\Admin\Desktop\AutoIT\Projects\new.au3 (23) : ==> Subscript used with non-Array variable.: GUICtrlCreateLabel($INI2[1][1], 20, $v) GUICtrlCreateLabel($INI2^ ERROR My UDF's : _INetUpdateCheck() My Programs : GameLauncher vAlpha, InfoCrypt, WindowDesigner, ScreenCap, DailyRemindersPick3GeneratorBackupUtility! Other : Bored? Click Here! Link to comment Share on other sites More sharing options...
enaiman Posted August 12, 2007 Share Posted August 12, 2007 It looks like ... it could be ...but it is not. It is a good practice to not try to create such arrays. Indeed, you have first created an array ($INI) and in each element of it you have put another array but this is not making $INI to be a 2 dimension array. You get this error because both $INI and $INI2 are 1 dimensional arrays as returned by IniReadSectionNames. SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Mast3rpyr0 Posted August 12, 2007 Author Share Posted August 12, 2007 (edited) $INI is only needed for the Ubound part in the For loop, which works. The one im concerned about is $INI2 why is it not a 2 array? In the array display it looks like it is. EDIT: $INI2 is not connected to $INI at all. Edited August 12, 2007 by Mast3rpyr0 My UDF's : _INetUpdateCheck() My Programs : GameLauncher vAlpha, InfoCrypt, WindowDesigner, ScreenCap, DailyRemindersPick3GeneratorBackupUtility! Other : Bored? Click Here! Link to comment Share on other sites More sharing options...
enaiman Posted August 12, 2007 Share Posted August 12, 2007 Sorry - been a little confused (heh - monday morning) Your ini sections names are [1], [2] and so on? If this is the case then you shouldn't have any problems with your script. If the section names are different (and I guess they are) then IniReadSection will not return an array -> $INI2 won't be an array -> that error ... in this case you need to replace $i with the proper section name ($INI2 = IniReadSection(@ScriptDir & "\config.ini", $i)) and to modify the code accordingly. Sorry about the confusion in my previous post SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) Link to comment Share on other sites More sharing options...
Mast3rpyr0 Posted August 13, 2007 Author Share Posted August 13, 2007 (edited) Yes thats what the names are. heres a sample ini [1] Reminder=Write A Program Time=11 Days=Every Day [2] Reminder=Write A Program Time=15 Days=Monday-Friday [3] Reminder=Write A Program Time=23 Days=Wednesday The script works fine until i try to use the data in the array, _arraydisplay will go through each section as it loops until i try to use the array. Edited August 13, 2007 by Mast3rpyr0 My UDF's : _INetUpdateCheck() My Programs : GameLauncher vAlpha, InfoCrypt, WindowDesigner, ScreenCap, DailyRemindersPick3GeneratorBackupUtility! Other : Bored? Click Here! Link to comment Share on other sites More sharing options...
The Kandie Man Posted August 13, 2007 Share Posted August 13, 2007 I didn't look at it much, but this fixes the problem with it crashing: #include <array.au3> $INI = IniReadSectionNames(@ScriptDir & "\config.ini") Local $v = 70; declare a variable outside of a loop, otherwise you will keep declaring it over and over which is extremely inefficient For $i = 1 To Ubound($INI)-1 Step 1 $INI2 = IniReadSection(@ScriptDir & "\config.ini", $i) _ArrayDisplay($ini2) GUICtrlCreateLabel($INI2[1][1], 20, $v) Next Remember, since arrays are zero based, you must do Ubound($INI)-1. This is because the array starts at zero, so the ubound will always be one larger. That is why you must subtract 1 from the ubound. I hope that made sense. -The Kandie Man ;-) "So man has sown the wind and reaped the world. Perhaps in the next few hours there will no remembrance of the past and no hope for the future that might have been." & _"All the works of man will be consumed in the great fire after which he was created." & _"And if there is a future for man, insensitive as he is, proud and defiant in his pursuit of power, let him resolve to live it lovingly, for he knows well how to do so." & _"Then he may say once more, 'Truly the light is sweet, and what a pleasant thing it is for the eyes to see the sun.'" - The Day the Earth Caught Fire Link to comment Share on other sites More sharing options...
Mast3rpyr0 Posted August 13, 2007 Author Share Posted August 13, 2007 Thanks so much guys, Kandie that did it. My UDF's : _INetUpdateCheck() My Programs : GameLauncher vAlpha, InfoCrypt, WindowDesigner, ScreenCap, DailyRemindersPick3GeneratorBackupUtility! Other : Bored? Click Here! Link to comment Share on other sites More sharing options...
enaiman Posted August 13, 2007 Share Posted August 13, 2007 Great I know about arrays being 0 based but ... I didn't think to look there for the trouble ... and that's why we need help sometime. Cheers, SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :) 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