LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I dynamically select the data type of programmatic Shared Variable API?

Solved!
Go to solution

I am trying to create a setup for open shared variable connections using the Programmatic API. It seems to me like the cleanest way to do this would be to put one "open and verify" routine in a FOR loop, then call it for each variable in the library.

 

The issue I am running into is I have diffrent data types in my library (using a Modbus IO server, and have "boolean" and "single" data types in my library. How can I dynamically select the data type for the shared variable API?

 

 

see the attached snipit.

 

Thanks

--------------------------------------------------------------------------------------------------

--CLD--
LV 6.1 to 2015 SP1
0 Kudos
Message 1 of 4
(2,776 Views)

The data type is defind at compile time and you can't mix them like you are planning.

 

Unless you set up your shared variable to type Variant, but you will have to convert them back the correct data type on the read end.

Omar
0 Kudos
Message 2 of 4
(2,770 Views)
Solution
Accepted by topic author JimMacD

What I ended up doing was making a subVI to Open, Read, Write, and Close each data type I am using, the packaged them into 4 Polymorphic SubVIs  (Polymorphic Open, Poly Read, etc....)

 

Now all I have to do I drop in the Polymorphic SubVI and it automatically switches to the appropriate data type

--------------------------------------------------------------------------------------------------

--CLD--
LV 6.1 to 2015 SP1
0 Kudos
Message 3 of 4
(2,735 Views)

I am in the process of doing something similiar, however I first am getting the Data Type for each variable in the library.  But this value is a variant.  How can I convert this to the data type that is required for the open variable connection?  Do the subvi's that you created do this?  If  not,  can you show me the vi's you made, I could change my approach to the same as yours.

 

Terry

0 Kudos
Message 4 of 4
(2,509 Views)