12-02-2019 03:39 AM
Hi! I'm new to LabVIEW and I'm trying to create a simple calculator, I'm using a flat sequence to get the first number with event structure and then get the second number also with event structure also.
So far I'm not able to choose the second number, because when i press the button to choose the first number, the event at the first frame gets triggered, and it also gets passed to the second frame, so the same event goes for the first and second number.
I'm wondering how is it possible to stop the event from passing between the frames automatically? and if there is a better way to do this?
I also tried it with while loop, but the event get passed the same way from one iteration to the another, so the same thing happens.
My VI is attached, thank you for your help!
12-02-2019 03:58 AM
All you need is one toplevel loop and one event structure with several events.
(Your code makes no sense. Start with some simple tutorials. Learn about the basics of dataflow. Search the forum and examples for calculator to get some ideas.)
12-02-2019 04:09 PM
When using event structures, I would recommend reading up on the caveats and recommendations.
https://zone.ni.com/reference/en-XX/help/371361R-01/lvhowto/caveatsrecmndtnsevnts/
To explain at a high level what is happening in your VI the event isn't being "passed" into the second frame, the click is actually sending that event to both structures at the same time. Each event structure is configured to handle a set of events and when one of those events happens it ends up in that event structures queue. When it comes time for the event structure to execute, it looks at its queue and if there is an event that needs to be handled it goes ahead and executes that case. When you run your VI and click "1" LabVIEW basically sees that there are 2 observers waiting for that event and separately tells both of those observers that "1" has been clicked.
As mentioned, you could probably do this whole thing by putting the event structure in a while loop. You'll also want to look up shift registers for storing information between iterations.
12-03-2019 03:51 AM
Hi altenbach! thank you for your answer.
you are right the code didn't make much sense, i have changed it and it kind of works correctly now with one while loop and one event structure, but i'm still learning how data flow works.
I looked up some calculator examples and they were very helpful.
12-03-2019 04:08 AM
Thank you Jacomson for your detailed explanation, i wasn't sure how the events were being handled, but now it's much clearer.
I will take a look at the events caveats, and understand all the details.
12-03-2019 10:36 AM
@salaryunis wrote:
Hi altenbach! thank you for your answer.
you are right the code didn't make much sense, i have changed it and it kind of works correctly now with one while loop and one event structure, but i'm still learning how data flow works.
I looked up some calculator examples and they were very helpful.
Good! It seems you are a fast learner. Fell free to ask more question or show us your "kinda works" efforts and we probably can speed up the learning curve even more with specific advice. Good luck!
12-05-2019 04:07 AM - edited 12-05-2019 04:11 AM
I have changed it a bit and now i got this VI. Now it works for individual numbers (1 digit) only, and simple math operations.
Any ideas on how to implement it for larger more digit numbers would be appreciated.
12-05-2019 05:44 PM
Your VI is broken. Did you attach the right one?
12-06-2019 04:19 AM
Hi altenbach, sorry it was the wrong VI.
12-10-2019 10:41 AM
Quick glance:
Have you looked at some of the calculator examples and discussions found in this forum?