LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Binding Shared Variables Programmatically

I want to know if it's possible to bind shared variables programmatically? I'm using "SharedVariableI/O" Property node, "Netwrk.URL" item. But htis doesn't work. I will appreciate greatly any help.
0 Kudos
Message 1 of 7
(3,812 Views)
 

Hello!

Is this what you are trying to achieve?

Programmatically Changing The URL of the Data Binding Source for Shared Variables
https://knowledge.ni.com/KnowledgeArticleDetails?id=kA00Z0000019RoKSAU&l=en-US

 

Regards,
Jimmie Adolph
Systems Engineering Manager, National Instruments Northern European Region

0 Kudos
Message 2 of 7
(3,804 Views)
Thanks but I've done exactly this and when I check shared variables property dialog box to see if the URL shared variable bound to, I find it hasn't changed.
0 Kudos
Message 3 of 7
(3,798 Views)
Hi Maryam,

After playing around with some example code I got this to work.

What are you doing/trying to do exactly?
Sarah

Applications Engineer | National Instruments | UK & Ireland
0 Kudos
Message 4 of 7
(3,779 Views)

Hi Sarah,

 

I'm developing a HMI system. I want to be sure that my bindings to the shared variables are correct after each change in location when some configuration file name or computer name change, so I want to rebind all variables at the first of each run to their resources.

 

I've done what Jimmie mentioned previously but it didn't change the URL shared variables are bound to.

 

0 Kudos
Message 5 of 7
(3,769 Views)
Hi Maryam,

I don't believe programmatically binding shared variables will permanently change the URL your variables are bound to, it will just change them for that run. If you need to do this then you will have to include code in your application that changes the URL each time the code is run.

The attached project demonstrates this. Extract the zip file, open the project file and expand the three libraries. The Variable Server VI is broadcasting data to the waveform variable. The Data Item Binding Client VI uses the bound waveform variable to read this data. If you have a look at the properties of the bound waveform variable you will see that it is bound to the waveform variable in the server library.

Open the Variable Server and the Data Item Binding Client VIs and run them. Then run the waveform1 VI that's in the Binding URLs.lvlib library. This writes a sine wave to "waveform1".

Once these three are running you can run the Bind URLs VI. This programmatically binds "bound waveform" to "waveform1" (instead of "waveform") and you will see the waveform in the Data Item Binding Client change from a random waveform to a sine waveform.

If you stop all these and run them again you will see that "bound waveform" is still bound to "waveform", not "waveform1". You need to run the Bind URLs VI again to change the URL that "bound waveform" is bound to.

If I understand you correctly, what you want to do is change the URL your variables are bound to the first time the code executes and then have that URL stay the same for subsequent executions, is that correct?

I've been thinking about it and you could do it by having a vi that runs once and stores the new URL in a location in memory that you can then access when needed in your code. Does that sound like something that could help?

Message Edited by SarahB on 08-02-2006 06:31 AM

Sarah

Applications Engineer | National Instruments | UK & Ireland
0 Kudos
Message 6 of 7
(3,733 Views)

Message Edited by SarahB on 08-02-2006 06:34 AM

Sarah

Applications Engineer | National Instruments | UK & Ireland
0 Kudos
Message 7 of 7
(3,728 Views)