Troubleshooting
please tell me why this 'for loop' does not work? (simple)
Started by m127 on .
Sign in or create an account to join the conversation.
never mind; silly question
Subject: Re: please tell me why this 'for loop' does not work? (simpl
for (i=myVals[0]; i<Major[1]; i++)
{
mySwitches.x[i]=1;
}
This will work but i dont think it will do what you want What should this loop do?
Subject: Re: please tell me why this 'for loop' does not work? (simpl
HiWell it does work in some way - It sets mySwitches.x[45] to 1; but like Rie said What do you expect it do?
And what is the Major array?? If Major[1] is less than myVals[0] it does nothing . . .
Also 'i' never gets incremented so it won't change from it's initial value of 45 . . .
'i' gets set to 45
if 'Major[1] is less than 45 it exits
if it larger than 45 the loop runs and sets mySwitches.x[45] to 1
counter increments
if Major[2] is less than 45 it exits
if larger, the loop runs and sets mySwitches.x[45] to 1
I think you will need either a 'while' or 'do while' rather than a 'for' . ..
Also sending a small example project is often better then just sending a script . . .
MM