please tell me why this 'for loop' does not work? (simple)

Discuss problems and solutions.
Post Reply
m127
Newbie
Posts: 32
Joined: 14 Dec 2011 07:57

please tell me why this 'for loop' does not work? (simple)

Post by m127 »

never mind; silly question
Last edited by m127 on 10 Dec 2012 07:44, edited 1 time in total.
Rie
Newbie
Posts: 5
Joined: 17 Nov 2012 00:16

Re: please tell me why this 'for loop' does not work? (simpl

Post by Rie »

Code: Select all

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? :)
Macciza
Regular
Posts: 1315
Joined: 07 Dec 2011 04:57
Location: Sydney, Australia.

Re: please tell me why this 'for loop' does not work? (simpl

Post by Macciza »

Hi
Well 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
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
Post Reply