04-13-2017 09:21 AM
Dear Friends,
As new user of lab view, I stuck how to deal with case structure and more specifically in value change.
Below Picture is part of my code which I am trying to fire an action in case structure.
I use +1 as counter but I don't know how to program for different value.
for example if numeric is equal to 1 save the picture in excel in a defined position, make array automatically and when is equal 2 do the same but define a new position for picture in excel.
I am not able to define a logic for different number as trigger
I really appreciate all your helps
04-13-2017 09:39 AM
Please, do not attach a picture of code. Attach the actual code. We can't move things around in a picture, we can't rewire a picture, we can't try to execute a picture (though I'm often tempted to execute those who post the pictures ...).
Event Structures are very good for handling Front Panel controls. If a control doesn't change, you can just read it. But if you are going to change it, you don't want to spend a lot of CPU time saying "Did it change? Did it change? Did it change?", so you use an Event Structure, which take no CPU time until an "Event" (Value Changed?) occurs.
As you are just learning LabVIEW, you are programming inside the Event Loop. A more advanced technique (which you'll learn once you master the basics) is to have two loops operating in parallel, a "Producer" loop (the Event Loop) that says "Hey, something changed, do some processing" and a "Consumer" loop that carries out the wishes of the Producer. Data are typically passed from Producer to Consumer via a Queue, and in many cases, the Consumer is something called a State Machine, with different "States" being specific code to execute under specific circumstances.
But first, post your code that shows what you want to do, and we'll explain how to use the simple Event Loop to do it. But we need the code ...
Bob Schor
04-13-2017 04:42 PM
Thanks Bob for your reply
Unfortunately, I can't upload the whole code while it is confidential and need lots of hardware to run.
This time I tried to make a better screenshot.
The point is I am wondering to find a way to apply to get same result that I am getting now.
My method is stupid and only works for two entries
04-13-2017 04:59 PM
Ay, ay, ay! I saw "too much", namely a Stacked Frame Structure! Frame Structures are (mostly) unnecessary, and Stacked Frame Structures are Evil.
So I'm looking at your picture, wondering where is the Event Loop?
Don't send another screen shot. Instead, open LabVIEW, type Ctrl-N to open a new, blank VI, copy the code fragment you show in your Event structure 2 picture, paste it onto the blank Block Diagram, put a few controls or indicators in to minimize the Errors (put in things corresponding to the Local Variables and Property Nodes, for example) and attach that. Also, say briefly what you want to code to do ("If N is Even, do this, otherwise do that") -- if your logic is "wrong" and doesn't do what you want, it doesn't make much sense to "clean it up" and still have it behave the same (wrong) way!
When I look at a "picture" such as your attachment, I'm forever clicking the Case element to "see the other Case", and similar "things that don't work".
Bob Schor