damian666 Posted July 12, 2009 Share Posted July 12, 2009 Func BUTTON2CLICK() GUICtrlSetData($ListView1_0, "") GUICtrlSetData($ListView1_0, "|" & "") GUICtrlSetData($ListView1_0, "|" & "|" & "") GUICtrlSetData($ListView1_1, "") GUICtrlSetData($ListView1_1, "|" & "") GUICtrlSetData($ListView1_1, "|" & "|" & "") GUICtrlSetData($ListView1_2, "") GUICtrlSetData($ListView1_2, "|" & "") GUICtrlSetData($ListView1_2, "|" & "|" & "") GUICtrlSetData($ListView1_3, "") GUICtrlSetData($ListView1_3, "|" & "") GUICtrlSetData($ListView1_3, "|" & "|" & "") GUICtrlSetData($ListView1_4, "") GUICtrlSetData($ListView1_4, "|" & "") GUICtrlSetData($ListView1_4, "|" & "|" & "") GUICtrlSetData($ListView1_5, "") GUICtrlSetData($ListView1_5, "|" & "") GUICtrlSetData($ListView1_5, "|" & "|" & "") GUICtrlSetData($ListView1_6, "") GUICtrlSetData($ListView1_6, "|" & "") GUICtrlSetData($ListView1_6, "|" & "|" & "") GUICtrlSetData($ListView1_7, "") GUICtrlSetData($ListView1_7, "|" & "") GUICtrlSetData($ListView1_7, "|" & "|" & "") GUICtrlSetData($ListView1_8, "") GUICtrlSetData($ListView1_8, "|" & "") GUICtrlSetData($ListView1_8, "|" & "|" & "") GUICtrlSetData($ListView1_9, "") GUICtrlSetData($ListView1_9, "|" & "") GUICtrlSetData($ListView1_9, "|" & "|" & "") Call("SET_GUI") GUICtrlSetData($Label1, "Done!!!") EndFunc ;==>BUTTON2CLICK i want to know if there is a way to shorten the above piece of code, this seems like a waste of space to me. any help will be apriciated ^^ Damian666 and proud of it!!! Link to comment Share on other sites More sharing options...
dantay9 Posted July 12, 2009 Share Posted July 12, 2009 Here you are. Func BUTTON2CLICK() For $x = 0 To 9 GUICtrlSetData($ListView1[$x], "") GUICtrlSetData($ListView1[$x], "|" & "") GUICtrlSetData($ListView1[$x], "|" & "|" & "") Next SetGUI() GUICtrlSetData($Label1, "Done!!!") EndFunc As you can see, when you do something repetitive like this, it is beneficial to put the controls into an array. Link to comment Share on other sites More sharing options...
damian666 Posted July 12, 2009 Author Share Posted July 12, 2009 nice ^^ i didnt knew those were allowed with $variables thanx a lot, this saves a lot of coding Damian666 and proud of it!!! Link to comment Share on other sites More sharing options...
dantay9 Posted July 12, 2009 Share Posted July 12, 2009 You didn't know arrays were allowed to have variables? That is an important concept. Putting like variables or controls into an array can allow you to perform the same function on all of them much easier. Just think if you have 25 or 50 controls that had to be edited. Link to comment Share on other sites More sharing options...
damian666 Posted July 12, 2009 Author Share Posted July 12, 2009 (edited) hmm... then what would cause this? ==> Subscript used with non-Array variable.: GUICtrlSetData($ListView1[$x], "") GUICtrlSetData($ListView1^ ERROR ->17:26:37 AutoIT3.exe ended.rc:1 oh, i know arrays use variables, just didnt know that would work on controls too >.< Edited July 12, 2009 by damian666 and proud of it!!! Link to comment Share on other sites More sharing options...
dantay9 Posted July 12, 2009 Share Posted July 12, 2009 (edited) Oh! sorry. Forgot to declare arrays. You need to declare the array at the beginning of the script. Use "Dim $ListView1[10]" because there are 10 elements in the array. Edited July 12, 2009 by dantay9 Link to comment Share on other sites More sharing options...
damian666 Posted July 12, 2009 Author Share Posted July 12, 2009 (edited) oh yeah >.< sheesh...that i myself didnt notice that but should that not be "Dim $ListView1_[10]" ??notice the underscore? yeah, that fixed it, thank you for your time Edited July 12, 2009 by damian666 and proud of it!!! Link to comment Share on other sites More sharing options...
damian666 Posted July 12, 2009 Author Share Posted July 12, 2009 ok, seems like i still dont get it, the above works, but this wont ??? For $x = 0 To 9 $string1 = IniRead($lic, $number, "info1", "") $string2 = IniRead($lic, $number, "info2", "") $status = IniRead($lic, $number, "Status", "") If Not @error Then GUICtrlSetData($ListView1_[$x], $string1) GUICtrlSetData($ListView1_[$x], "|" & $string2) GUICtrlSetData($ListView1_[$x], "|" & "|" & $status) EndIf $number += 1 Next i mean, wtf... its the same principle right? it does read the info correct, but wont insert it in the control... Damian666 and proud of it!!! Link to comment Share on other sites More sharing options...
Developers Jos Posted July 12, 2009 Developers Share Posted July 12, 2009 You also need to change your GUICtrlCreate....() statements to use the array. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
damian666 Posted July 12, 2009 Author Share Posted July 12, 2009 ooooh yeah... who says you cant learn after a few years ^^ thank you both Damian666 and proud of it!!! 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