LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sub VIs and shared variables

Is there any way to pass the address of a shared variable to a sub VI. I would like to have access to the variablew in the sub vi (OPC Server accessing vars etc).
0 Kudos
Message 1 of 5
(3,368 Views)
Well, why don't you just add the same variable into the subVI as in the main VI? What exactly are you trying to do over here?
Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 2 of 5
(3,355 Views)

The variable may change depending on the instance of the Sub VI. If I were to include the actual reference to the variable in the subVI (global def), then I could not use the subVI in a universal fashion. In addition the shared variable are defined as single process, as similar instances of these VIs are running in parallel.

 

In effect, multiple VIs where the only difference is the global definition of the shared variables. Inside each VI, there can be similar calls to a sub vi with different variables.

 

I would like to be able to cll a SubVI using a shared variable by reference and not value if possible (without the overhead of creating arrays etc to house all the shared variables (and cal;ling with an index), as this would severely limit flexibility).

0 Kudos
Message 3 of 5
(3,337 Views)
I believe you can use the datasocket VI's to call the shared variable.  Then all you would have to pass into the code is a string defining the address of the shared variable you want to access.
0 Kudos
Message 4 of 5
(3,330 Views)

Yup, that would be the best way to do this. You can open the Datasocket connection using the following for the URL:

psp:\\localhost\[Library]\[VariableName]

 

Adnan Zafar
Certified LabVIEW Architect
Coleman Technologies
0 Kudos
Message 5 of 5
(3,327 Views)