imacrazyballoono Posted June 20, 2006 Posted June 20, 2006 Can I a loop that is something like this? Look at line 6, I want the variable to be one more each time it goes through the loop. I.E. first time variable would be $color[1]. Second would be $color[2] and so on. $time = 1 do $mult = $time * 2 $num = $time * 10 $left = 958 - $num $color[$time] = $mult $time = $time + 1 until $time = 5 MsgBox( 0, "", $color[1] ) MsgBox( 0, "", $color[2] ) MsgBox( 0, "", $color[3] )
Developers Jos Posted June 20, 2006 Developers Posted June 20, 2006 Can I a loop that is something like this? Look at line 6, I want the variable to be one more each time it goes through the loop. I.E. first time variable would be $color[1]. Second would be $color[2] and so on. $time = 1 do $mult = $time * 2 $num = $time * 10 $left = 958 - $num $color[$time] = $mult $time = $time + 1 until $time = 5 MsgBox( 0, "", $color[1] ) MsgBox( 0, "", $color[2] ) MsgBox( 0, "", $color[3] ) Yes you can after you have Dim(ed) the array... Dim $Color[6] I would use a "For $time = 1 to 5 ... Next" loop, but this should also work 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.
dirtymafia Posted June 20, 2006 Posted June 20, 2006 (edited) How would I dim it?dim $color[6] You could also check the help file for 'dim'. Edited June 20, 2006 by dirtymafia
Developers Jos Posted June 20, 2006 Developers Posted June 20, 2006 How would I dim it?It is in my answer.... and try also to open the help file and read about suggestions made before posting a reply. 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.
imacrazyballoono Posted June 20, 2006 Author Posted June 20, 2006 I read the documentation on dim, it is very confusing. Can someone show me how it works?
dirtymafia Posted June 20, 2006 Posted June 20, 2006 I read the documentation on dim, it is very confusing. Can someone show me how it works?dim basically initiates a variable. You can do the same with normal variable by doing this: $variable = "" You need to use Dim in the case of an array to make it useable as an array. When you do dim $color[6] you are getting the ability to store in $color[0] $color[1] $color[2] and so on up to 5. Keep in mind you use 0 first not 1. I'm not the best at explaining but maybe that will help give you a 50000 ft. view
imacrazyballoono Posted June 20, 2006 Author Posted June 20, 2006 it helped a lot thanks. So I would just put dim $color[6] at the top and then it would work? so like this: dim $color[6] $time = 1 do $mult = $time * 2 $num = $time * 10 $left = 958 - $num $color[$time] = $mult $time = $time + 1 until $time = 5 MsgBox( 0, "", $color[1] ) MsgBox( 0, "", $color[2] ) MsgBox( 0, "", $color[3] )
dirtymafia Posted June 20, 2006 Posted June 20, 2006 (edited) it helped a lot thanks. So I would just put dim $color[6] at the top and then it would work? so like this: dim $color[6] $time = 1 do $mult = $time * 2 $num = $time * 10 $left = 958 - $num $color[$time] = $mult $time = $time + 1 until $time = 5 MsgBox( 0, "", $color[1] ) MsgBox( 0, "", $color[2] ) MsgBox( 0, "", $color[3] )try it..should work Also if you use a For next it will automatically incrememt your $time like this dim $color[6] dim $time For $time = 1 to 5 $mult = $time * 2 $num = $time * 10 $left = 958 - $num $color[$time] = $mult msgbox(0,"",$color[$time]) Next Edited June 20, 2006 by dirtymafia
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