LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Two (non-simultaneous) inputs to a string

I'm struggling to get my head around the programming mindset used in
LabVIEW (I'm a C++/C programmer, usually). I just can't seem to do
the simplest things, sometimes - at the moment, I'm trying to do this:

initialise a string
do some processing
set the string to the result

I just can't get it right. I've got a sequence structure, with the
string outside it, and I'm trying to wire a string constant to it in
the first frame, and in the second frame I'm trying to wire the output
from an exception handler. But I can't get labVIEW (v7) to realise
that only one of these inputs will be active at a time. (The same
problem would hold for a case statement - if true, set the string to
"TRUE", if false, set the string to "FALSE").


How do I do this? I suspect I'm approaching it from totally the wrong
point of view, but I don't know how else to approach it.
0 Kudos
Message 1 of 5
(2,845 Views)
For a sequence structure what you'll have to do is use a local variable in one of the frames and the indicator inside of the other frame (unless it's inside the last frame). With a case statement, the indicator would be outside the case statement and inside each case, wire a constant in each case to the indicator.
0 Kudos
Message 2 of 5
(2,845 Views)
The biggest concept change in going from C/C++ to LabView is the concept of dataflow-driven execution. On the LabView diagram, data flows in wires from one node (control terminal, constant, function, sub-VI, etc.) to another. The execution order is determined by the flow of data in the wires. A node will start to execute only when it has data from all the wires to its inputs. The node will not present any outputs until its execution is complete and all of its outputs are available.
I went back to the basics here because of the "non-simultaneous" phrase in your question. Inputs to the string concatenation function (or any function) do not need to be simultaneous. You do not need a sequence to build a string.
Here's another soapbox-second: sequence struc
tures are easy for text-based programmers to understand, but sequences are often over-used. Many programmers just beginning to use LabView use sequences when dataflow will suffice. Your brief explantion of your application doesn't show me a need for a sequence.
But enough about me. To get back to your question, in a stacked sequence (the only sequence structure available prior to LabView 7), you can use sequence locals to pass data from one frame to a subsequent frame. Right-click on the sequence structure right-hand border and select Add Sequence Local. Wire the source of the local in the first frame it's used. Wire as many subsequent frames as needed to the local. In a Flat Sequence (first available in LabView 7), just wire through a tunnel from one frame to the next (the tunnel will automatically get created when you wire from one frame to the next).
Here's a LabView 7 example which shows how data is passed through sequence and case structures. It is not an example of when
you need to use sequences: niether sequence in the example is needed. But it shows how they're used.
Message 3 of 5
(2,845 Views)
I have worked with quite a bit of labview code developed by C people. (i used to be a C programmer my self). Typically new c->Labview programmer endup using lots of sequence cases. I would suggest not to use any. In most cases the data flow could solve the problem.

In your case i guess you are trying to connect 2 strings to one output in a stacked sequence. This is not valid in labview. Try a Case structure instead.
0 Kudos
Message 4 of 5
(2,845 Views)
> initialise a string
> do some processing
> set the string to the result
>

Hopefully the other posts already have you on your way, but I'll add a
bit more just in case.

The controls and indicators on a panel are UI elements and shouldn't
really be used for storage. When you initialize a string for UI
purposes, write to it using either a local variable, or the value
property. You don't need to store or initialize things otherwise, just
feed values into wires and pipe them where they need to go.

Greg McKaskle
Message 5 of 5
(2,845 Views)