i am having a problem with while loops, i have two while...

i am having a problem with while loops, i have two while...

Post by Mads » Sun, 07 Mar 2004 20:01:44


Could you please define exactly what it is you want to get as an
output and where you are to use that output?

If you just terminate the inner loop the outer loop will iterate and
thus restart the inner loop. The inner loop has it's conditions set to
stop but that just means that it will run just one iteration...so now
the outer loop runs continously, making the inner loop run one
iteration each time.

In this case you'll get multiple values out of the outer loop since it
is running multiple iterations. If all you wanted was one value, the
one from the last iteration of the inner loop the first time it was
called you'll need to terminate the outer loop at the same time as the
inner by wiring the stop of the inner to the conditional terminal of
the outer as well.

In short - try to figure out what you want and make sure the logic of
the code really fits that...

By the way; the use a a sequence is not necessary. If you want to
clear the array prior to running the loop just wire the error output
of the property node to the left border of the outer while loop, that
way data flow ensures the right order of execution and the code
becomes easier to read (sequences is normally avoided where data flow
can be used instead, data flow should be the primary controller of
execution you use when writing G). The use of a property node for this
task is not the best option either (in this case you could use an
invoke node to reset the default value instead anyway) - use locals
for this (locals too are to be avoided though - if wiring can do the
job).
 
 
 

i am having a problem with while loops, i have two while...

Post by gauravmcgi » Mon, 08 Mar 2004 01:27:31

first thanks for replying. But i will be more specific this time.
Since i have already posted the vi i will try n explain based on that.
What primarily i want is that when i doing data acquisition i change
the weight parameter every time i think my voltage reading(which in
this case is simulated by random number) reaches some desired value
which is completely dependent on the user when he thinks that the
inner loop has reached a specific value he will terminate the inner
loop. Now i dont want the outer loop to terminate since i want my
experiment to continue i will be adding more weight and taking a new
voltage reading, so after putting a new weight i will flip the switch
back again to take a new reading.
Now the problem is i want the value to recorded from the inner
loop when the switch is fliiped to off. Which it does fine initially
but later it even when the inner loop has terminated the random number
continues to generate numbers which i thought shudnt have happened
since the innner loop is off and it continues to write the values in
the array(which is totally junk since i just wanted one value when the
switch was flipped).
Can you help me with proper initialisation routines if you think
property node is not gud enough.

 
 
 

i am having a problem with while loops, i have two while...

Post by gauravmcgi » Mon, 08 Mar 2004 01:30:02

plus is there an easier way to pause the execution becuase if there is
only one loop and swith it off it terminates the program which i
definately dont want. As this is to be used by people who have no idea
abt labview.