LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Urgent !! How do I keep the value generated by one Event case, and use/edit it in other event cases (inside the same Event Structure)??

Hi there experts!!
 
A super simple question I need answered very urgently !!
 
I have one event structure, with 4 event cases, inside one while loop.  Everything is standard so there is nothing wrong with the Event or While structure.
 
The question is, when I generate a value inside Event Case 0, how do I keep that value so it won't get deleted when other Event Cases are excuted??
 
I want to keep that value and be able to use it in Event Case 3 (After the value is generated by case 0, I just want to be able to use it in other cases).
 
Secondly, what if I want to change that value in Case 2 ???  How do I update it??
 
Please help me ASAP.  Thank you so very much !!!  cheers.
 
Warmest Regards,
 
David
 
0 Kudos
Message 1 of 6
(3,056 Views)
Shift Registers!

Shift registers are designed exactly for this purpose. You pass data to them from inside the loop and it passes the data to the next loop iteration.

Right click on the edge of the While loop and select, "Create Shift Register". You'll see two nodes appear on both the left and right sides of the While loop. They work in pairs. You can wire a value from inside the While loop/Event structure to the node on the right border and that value will be available in the corresponding register on the left border on the next loop iteration. You can add as many shift registers as needed.

That should be what you need. Let us know if you have any more questions.

Ed


Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 2 of 6
(3,052 Views)
Thx Ed for your reply!!

This was exactly what I did, but if Event case 1 is executed, the value generated by case 0 will be zero, hence I cannot use it in case 3.
 
also, if I execute case 3 straight after case 0, i can get the value only once.  But I really need to keep it.
 
please kindly look at my attached VI, you will understand what I mean very quickly !!!

it a very very veyr very simple VI !!!
 
thank you very much again, hope to hear from you soon.
 
best wishes,
 
David
0 Kudos
Message 3 of 6
(3,050 Views)
I see.

What you need to do is right click on the tunnel (little blue square) leaving the Event Structure going to the shift register and de-select, "Use default if Unwired". With this option checked, everytime a case runs that does not have a wire connected to the tunnel, the default value for that data type is passed out of the tunnel. (0 for numbers, FALSE for boolean, an Empty string...) Default does not mean pass what ever went through last time.

So uncheck that option and you'll need to wire the value through all of the Event cases. This will keep the value in the shift register. You can do this without unchecking the Default option, but you'll be forced to wire all the cases with it unchecked so you're sure not to miss any.

See if that fixes it.

Ed


Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 4 of 6
(3,048 Views)
Thanks alot Ed !!
 
This works.  I just have to (short) wire the square terminals in every event case to maintain the value.
 
Thank you very much!!
 
I am quite new to "LabVIEW".  It sure is interesting (but fraustrating when I got stock on something so simple like this, which won't happen in text-based-programming languages).
 
cheers mate!
 
 
Best wishes,
 
David
0 Kudos
Message 5 of 6
(3,042 Views)


(but fraustrating when I got stock on something so simple like this, which won't happen in text-based-programming languages).

Forget a wire in LabVIEW, forget a semicolon in C. It's all relative. Smiley Wink


Ed Dickens - Certified LabVIEW Architect
Lockheed Martin Space
Using the Abort button to stop your VI is like using a tree to stop your car. It works, but there may be consequences.
0 Kudos
Message 6 of 6
(3,017 Views)