layer Posted December 31, 2005 Share Posted December 31, 2005 well, since i REALLY suck with arrays, i need to work on them, i still need some more work with them, but this is as dirty as ive ever gotten with arrays Func makeRndm() $num = Random(0, 3, 1) return $num EndFunc Func chooseGreet() $GreetNum = makeRndm() Dim $greet[4] $greet[0] = "Hello";English $greet[1] = "Hei";Norwegin(sp?) $greet[2] = "Bonjour";French $greet[3] = "Hola";Spanish MsgBox(0, "Greetings", $greet[$greetnum]) EndFunc chooseGreet()yea i know i didnt need the makeRndm function but making function calls is fun ! FootbaG Link to comment Share on other sites More sharing options...
Guest Mixture63 Posted December 31, 2005 Share Posted December 31, 2005 What? The great layer has problems with arrays? Your a good coder I'm suprised you having trouble with arrays. Arrays are easy. Of course, I seldom use them anymore. I should start using them again. I always use them in C++ though. Link to comment Share on other sites More sharing options...
layer Posted December 31, 2005 Author Share Posted December 31, 2005 (edited) another one, im searching for more complex ones now.. but i gotta leave soon for dinner..GUICreate("Array of control creation") GUISetState() Dim $ctrl[6] For $i = 0 to UBound($ctrl) - 1 $ctrl[$i] = GUICtrlCreateLabel($i, 10, 10 + ($i*20)) Sleep(1000) Next GUICtrlCreateLabel("Tada !", 10, 10 + ($i*20)) Sleep(1000) MsgBox(0, "", UBound($ctrl))edit: modified according to Valik's improved code Edited December 31, 2005 by layer FootbaG Link to comment Share on other sites More sharing options...
Valik Posted December 31, 2005 Share Posted December 31, 2005 another one, im searching for more complex ones now.. but i gotta leave soon for dinner.. GUICreate("Array of control creation") GUISetState() Dim $ctrl[6] $ctrl[0] = GUICtrlCreateLabel("0", 10, 10) Sleep(1000) For $i = 1 to 5 $ctrl[$i] = GUICtrlCreateLabel($i, 10, 10 + ($i*20)) Sleep(1000) Next GUICtrlCreateLabel("Tada !", 10, 10 + ($i*20)) Sleep(1000)layer, here's a little basic math for you. Anything multiplied by 0 is 0. That means your special case label you create outside the For loop is not necessary. You can get the same results with this: GUICreate("Array of control creation") GUISetState() Dim $ctrl[6] For $i = 0 to UBound($ctrl) - 1 $ctrl[$i] = GUICtrlCreateLabel($i, 10, 10 + ($i*20)) Sleep(1000) Next GUICtrlCreateLabel("Tada !", 10, 10 + ($i*20)) Sleep(1000) Link to comment Share on other sites More sharing options...
layer Posted December 31, 2005 Author Share Posted December 31, 2005 ^ doh ! you're right... ohhh... ok, i knew that anything multiplied by 0 was 0 but clearly i wasnt using that fact in my script took me a second to figure how the ubound was working, a little help from the helpfile and you cleared everything up, thanks FootbaG 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