LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

One input, two data types

Heres the deal...

 

I have a sub vi that has one input. This input needs to accept a string constant or an array of strings.

 

I tried a polymorphic vi and it dont work like I need it to.

 

I dont have a vi to upload at the moment but I think I can describe it well enough.

 

I have a case structure with two cases. One case has a string constant inside wired to an output tunnel.

The other case has an constant array of strings wired to the same output tunnel. I need this output tunnel to be wired into

one input of a sub vi.

 

The polymorphic vi works with either the string or the array, but not if they're in a case structure.

I'm assuming that the polymorphic vi wont work because the IDE cant tell what the input is at compile time.

 

I hope I've explained this well enough. If not I'll try to throw together a quick project.

 

Thanks in advance!

0 Kudos
Message 1 of 8
(3,002 Views)

You simply cannot have a single element and an array wired to the same output tunnel. Why don't you have the subVI inside each case?

Message 2 of 8
(2,995 Views)

You should get an error if you are trying to attach a string constant and an array of string constants to the same tunnel. Without seeing some of your code its hard to see ways around this. The vi that you need to pass this info too, can you just not always send an array and just check in this subvi the size of the array, if only 1 then you have your single string constant if >1 you have your string array? or does it specifically need to see either a single constant or an array?

 

 

Im sure if you post some code the problem will become clear and the solution forthcoming.

 

Rgs,

 

Lucither

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 3 of 8
(2,992 Views)

Thanks for the replies guys.

 

I'm updating a queued state machine and unfortunately I cant provide you with the code I'm working with.

 

I could throw together a quick, simple project and illustrate what I'm trying to do but you guys seem to already understand.

 

The subvi in question is the enqueue for the QSM.

 

Its fine though. I have a workable solution now. I was just hoping I could do this.

 

So, once again, thanks for the relplies!

0 Kudos
Message 4 of 8
(2,988 Views)

Well a polymorphic VI is the answer to this problem.

What you will need are three VIs:

  1. A VI that has a single string input
  2. A VI withan array of strings as input, in this VI you'll place VI No 1 in a for-loop
  3. A polymorphic VI that has two members: (1 and 2)

In the VI that uses the function you drop the polymorphic VI.

 

There are some items to think about when creating polymorphic VIs, the connector pane needs to be the same between the polymorphic VI (however you don't need to connect the same terminals).

There is a tool available at LAVA that helps in creating and editing polymorphic VIs.

 

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 5 of 8
(2,971 Views)

You must not have read my whole post.

0 Kudos
Message 6 of 8
(2,965 Views)

 


@WayneS1324 wrote:

 

I have a case structure with two cases. One case has a string constant inside wired to an output tunnel.

The other case has an constant array of strings wired to the same output tunnel. I need this output tunnel to be wired into

one input of a sub vi.


 

(Your first problem is already the fact that you cannot have a polymorphic output tunnel of the case structure, so you'll never make it to the subVI anyway.)

 

Don't overcomplicate things! How about using a string array with a single element in case #1? The subVI should easily be able to determine (think "array size"!) how many elements there are and act accordingly. No need for polymorphism at all. 😄

0 Kudos
Message 7 of 8
(2,942 Views)

Without seeing your code it is kind of hard to figure out exactally what you are trying to do. But if you want to connect multiple data types to a tunnel one option is using a variant. You could bundle that variant with an enum or something to describe it. Later unbundle that enum and you will know what the variant contains.

=====================
LabVIEW 2012


0 Kudos
Message 8 of 8
(2,926 Views)