12-18-2010 07:53 PM
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!
12-18-2010 08:30 PM
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?
12-18-2010 08:32 PM
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
12-18-2010 08:38 PM
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!
12-19-2010 04:17 AM
Well a polymorphic VI is the answer to this problem.
What you will need are three VIs:
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
12-19-2010 06:45 AM
You must not have read my whole post.
12-19-2010 12:02 PM
@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. 😄
12-19-2010 01:43 PM
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.