Hi, I am used to program in languages like C and Java, so I have a few problems in thinking in the LabView way.
My problem:
I have a case structure with three cases. Now I want to place this structure inside a loop and want to make sure that in each loop the next case is used. (1->2->3->1->2->...)
In Java I would use something like
int i = 1; while(true) { //do something before the switch switch(i) { case 1: /*do x*/; i++; break; case 2: /*do y*/; i++; break; case 3: /*do z*/; i=1; break; } //do something after the switch }
In my understanding I would need a variable which I can read and write from. How can this be done in LabView?
If you wire the Quotient & Remainder function to the iteration terminal of the while loop (x input) and a 3 to the y input, the x-y*floor(x/y) output will cycle 0,1,2,0,1,2... This is the same as the modulo function in other languages. Wire that value to the case selector. See the attached picture.
Actually, this one is really easy in LV. You can just wire the iteration counter terminal (the boxed "i" inside the while loop) to the case selector terminal (on the edge of the case structure). This will automatically change data types to I32 and act just like your switch statement with a break; (there is no way to do flow through) Just don't forget about case 0: and default: