# Really Easy Array question

## Recommended Posts

hi, I am totally learning autoit from absolutely no computer programing background so please bear with me. Im trying to do something but I dont know to say it. here goes

\$array[\$i] = Random Value not zero

For \$i=0 to \$i=4 step + 1

Do

Generalcommand(); makes \$array[\$i] = 0

until \$array[0] = 0 and \$array[1] = 0 and \$array[2] = 0 and \$array[3] = 0 and \$array[4] = 0

next

its the "\$array[0] = 0 and \$array[1] = 0 and \$array[2] = 0 and \$array[3] = 0 and \$array[4] = 0" that I dont know how to shorten, if i just say \$array[\$i] = 0 it will stop whenever one of them turns to zero and it happens to be looping there, How do i say for all of them in one line without being so repetitive. I dont know how to address all of the array values at the same time.

Thanks for all the help, its greatly appreciated, been wracking my brain for hours

Chris

Edited by tomagucci

##### Share on other sites

you just need this.

```For \$i = 0 To 4
GeneralCommand()
Next```
I don't see how you would need the do until statement unless your generalcommand() function changes the values of the array.

##### Share on other sites

it does, it changes them to zero, but i dont want it to stop doing it until all the values in the array have become zero. Does that make sense?,

sorry I saw where that was weird, does that help clairfy it?

Edited by tomagucci

##### Share on other sites

Then you still don't need the do until if it changes the element currently used. you could just mod the function to accept the current element/array as a parameter then pass it through the for/next loop.

##### Share on other sites

okay, the do is only the first part, here is the whole thing:

\$array[\$i] = Random Value not zero

For \$i=0 to \$i=4 step + 1

Do

Generalcommand(); makes \$array[\$i] = 0

until \$array[0] = 0 and \$array[1] = 0 and \$array[2] = 0 and \$array[3] = 0 and \$array[4] = 0

If \$array[0] = 0 and \$array[1] = 0 and \$array[2] = 0 and \$array[3] = 0 and \$array[4] = 0 then

exit

next

its more of the second part that isnt working, well technically it is, but the range of \$i changes sometimes and if i need to edit i need to go back in and change everyone. the actual range of \$i in my code is 12 and sometimes it will change to anywhere from 1-12

Edited by tomagucci

##### Share on other sites

why not just check the last value? also in your for you don't need the step, a Step 1 is implied.

##### Share on other sites

because it doesnt stay constant like that, the values of \$array are constantly changing, generalcommand() might change it to 0 once but it will change again, i need generalcommand() to keep working until every value is zero in one full loop

##### Share on other sites

You could try something like this to make it a bit easier (assuming you mod the generalcommand() to accept parameters).

```For \$i = 0 To UBound(\$array)
Generalcommand(\$array[\$i])
\$sum += \$array[\$i]
Next

If \$sum = 0 Then
Exit
Endif```

##### Share on other sites

generalcommand() modifies several things and \$array[\$i] cannot fit within the parameters. I really appreciate the help though

##### Share on other sites

what do you mean it can't fit within the parameters? a custom function can have infinite parameters so i don't see what you mean.

##### Share on other sites

hmm well i tried it, I dont know how to modify the parameters to get that method to work. is there another method? isnt there something that can directly address the array? does += mean add them all together? if it does then thats all i need.

Edited by tomagucci

##### Share on other sites

yeah += means add the value of whatever is after the = to the variable on the left of the +, so -= would be minus, &= would append the data, etc.

## Create an account

Register a new account