10-23-2010 08:34 AM
Hi
I have a while loop and I want to run another vi just one time when a condition in my while loop becomes true.
For example I want to send just one email when my input variable is between 4and 5.My loop may run N times and my condition may be olways true but I want to run the other VI or another while just one time
10-23-2010 08:56 AM
Create a flag to indicate whether the email subVI has run or not. The flag is just a boolean in a shift register. It does not need an indicator. Initialize it to false. On each iteration of the main while loop test the flag. If false, test the input variable. If true, call the subVI and set the flag to true. On all iterations after this the flag will be true and the input variable will not be tested and the subVI will not be called, because those things only happen when the flag is false.
Lynn
10-23-2010 12:19 PM
hello,
see attachement
-> johnsold , don't feel offensed your idea is correct, it just because when starting with Labview is not easy to put even a good idea on screen
Regards
Tinnitus
10-23-2010 08:29 PM
You can use the "First Call?" vi to run the code the first time it is called. From the help:
Indicates that a subVI or section of a block diagram is running for the first time. The First Call? function returns TRUE only the first time you call it after you click the Run button.
Find it on the synchronization palette.
-cb
10-24-2010 07:23 AM
many thanks for help
I have tried shift register and first call function but there is still one problem.when my input variable is between 4 and 7 using both methods my sub vi will be called and start running just for one time and never run again after that but what I would lilke is :if my input variable is between 4 and 7 my sun vi start running one time then if I enter 8 nothing happen but if I enter a value between 4 and 7 again it starts running just for one time again.so everytime the condition is true (after a false condition) my subvi starts running just for one time again.
10-24-2010 07:46 AM
???
did you try the vi posted ?
Regards
Tinnitus
10-24-2010 10:08 AM
yes Tinnitus
My problem with your vi is :My input might be between 4,8 for maybe 5 minutes.with your vi ,on the first iteration the value of is flag is false and my input is between 4 and 8 so it send a email.on teh second iteration the flag becomes true so no email but after that because my input value is still between 4 and 8 the flag become false again and another email will be sent so it will send 100 emails until I change the value to something out of this boundary.This is mot what I need
I want to send just one email even if my input is between 4 and 6 for 1 hour ,then send nothing if teh input value is not between 4 and 8 and then send another email again if my input value becomes for example 5
10-24-2010 10:46 AM
yes
there was a logical error
new attached vi should works correctly
10-24-2010 10:59 AM
Thanks tinnitus
it is still the same.u know instead of inputing a random value to In range function input a constant number like 6 then u will see it send email with no stop.while as I said I would like to send email just one time.As I said my input might be remain constant(between 4 and 😎 for about 10 minutes.using your VI it rapidly send email but if we change it to a random input value your vi will works perfectly.I think in this situation the First Call function works better because afetr first call ,the values becomes false and the subvi will not run again
but as I change my input value to 10 and again to something between 4 and 8 it will not send an email again because the first call function value remain false
10-24-2010 11:13 AM
i did the operation you said with the last vi and it works
it send email the first time it enter the range and only a new one if it goes out and enter again in the range
that what you asked, no ?
Regards
Tinnitus