LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Display message with a delay

Solved!
Go to solution

I want to display a message like after every one hour. I thought of using while loop with a delay. But I dont want a delay when the message is displayed for the first time. I want  an hour gap basically before the message is displayed again.

0 Kudos
Message 1 of 11
(3,869 Views)
Solution
Accepted by topic author Donajacob

Use a seperate while loop with an event structure. Put the timeout into a shift register initialized with zero (so it immediately fires the timeout event) and wire it to the timeout terminal. On the right, wire 1 hour (in ms) to the shift register. Now it will take an hour for the next timeout to occur.

(Also add an event for the stop button so this parallel loop will terminate if the program is stopped.)

0 Kudos
Message 2 of 11
(3,858 Views)

When you display the message the first time take a timestamp of the current time and add 1 hour to it.  Then compare the current time to the timestamp to determine when to display the message again.

0 Kudos
Message 3 of 11
(3,852 Views)

Thank you for the help but I have one more question. What if I dont want the message to be displayed if my condition is false and only display when its true.

0 Kudos
Message 4 of 11
(3,827 Views)

You put it in a case structure!

0 Kudos
Message 5 of 11
(3,823 Views)

I did it but when i change the case the loop is still running.

0 Kudos
Message 6 of 11
(3,816 Views)

Your architecture is completely turned inside out.

 

The while loop should be the outermost structure.

 

Then the event structure inside that.

 

Then the case structure inside that.

 

Then the dialog box inside the true case of that.

 

Be careful comparing two floating point numbers for equality.  Depending on how the numbers are entered or calculated, due to the limited resolution of decimal numbers in a binary computer language, you may find out two numbers you think would be equal may not be.

0 Kudos
Message 7 of 11
(3,809 Views)

I changed everything but once it goes to the true case. It doesn't shift to the false case

0 Kudos
Message 8 of 11
(3,798 Views)

I know you can't control a while loop from outside the loop. If not while loop is there anyway I can post a message when the code begins and then display it after an hour and so on. This should only happen in a True case. I only want the display message to be delayed not the rest of the code. Therefore I can't put the whole code in the while loop. I hope that helps to explain my problem.

0 Kudos
Message 9 of 11
(3,786 Views)

The controls and the comparisons belong inside the while loop.  Period.

 

If you want the true case to execute, you can do the comparison ORed with another comparison such as first call, or the while loop iteration =0, or timeout =0, or ....

0 Kudos
Message 10 of 11
(3,776 Views)