KnowledgeSponge Posted March 17, 2004 Share Posted March 17, 2004 I'm having a problem with a certain aspect of arrays. I've tried to figure this out through trial and error but not figuring it out. Probably overlooking something but need a little help. I am trying to declare a variable, say $number, through an inputbox (eg. How many of these do you want?) and then set the total for the array to that number. Then, I want each individual part eg $array[1] $array[2] to start declaring themselves through input boxes till it = $number. But i do not want to have to declare each part of the array myself to keep it open ended. I tried something like this $values = 0; $number = InputBox("blah", "How many of these do you want?") $var1 = $number; Dim $array[$var1] $var1 = 0; While $values = 0; Do $array[$var1] = InputBox("Hrmm", "Set this value.") $var1 = $var1 + 1; Until $var1 = $number; WEnd I just wrote it off the top of my head there cause i deleted what i had cause I couldn't get it to work so that might not be exactly right but you get the idea of what I'm trying to do from that. The prob is that it tries to set $array and $var to whatever the inputbox is which is not allowed and not what I want to happen anyways. I want each individual array to create itself and be declared in the inputbox so that the amount of times it could run would be exponential. Please let me know what I am missing in the equation here. Thanks for your help. Link to comment Share on other sites More sharing options...
scriptkitty Posted March 17, 2004 Share Posted March 17, 2004 this works; $values = 0; $number = InputBox("blah", "How many of these do you want?") Dim $array[$number] $var1 = 0; While $values = 0; while $var1 < $number $array[$var1] = InputBox("Hrmm", "Set this value.") $var1 = $var1 + 1; wend WEnd I would put an error check in for bad input. $values = 0; while 1 $number = int(InputBox("blah", "How many of these do you want?")) if $number>0 then exitloop wend Dim $array[$number] $var1 = 0; While $values = 0; while $var1 < $number $array[$var1] = InputBox("Hrmm", "Set this value.") $var1 = $var1 + 1; wend WEnd AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
Nutster Posted March 17, 2004 Share Posted March 17, 2004 Another version of this would use the FOR loop. $number = InputBox("How many of these do you want?", "InputBox Test") If IsNumber($Number) Then Dim $array[$number] For $value = 0 To $Number-1 $array[$value] = InputBox("What is entry number " & $value & "?", "InputBox Test") Next Else MsgBox(0,"Invalid Entry", "That was not a valid number.") EndIf David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd... Link to comment Share on other sites More sharing options...
KnowledgeSponge Posted March 17, 2004 Author Share Posted March 17, 2004 Thank you for the help guys. There is quite a bit of syntax I am unfamiliar with and trying to absorb by example and you are furthering my efforts. It's appreciated. 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