LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Scripting - Replace Control Reference Inside Flat Sequence

Solved!
Go to solution

Hi,

 

Just in the process of upgrading our software from 8.6 to 2011. One issue we are having is references seem to be different for old code. Example - If we create a new control reference, put it next to the old one, put a probe on them both, the references do not match when we run the vi.

This causes havoc with our very large amounts of code. We've contacted NI though our support subscription and they required an example which we can not really give.

 

Anyway...

 

I thought I would write a scripting vi to replace all the old references from our code with new references.

Problem is I can not replace a Control reference easily that is inside any kind of structure.

I need a way of getting a reference to a parent strucure, I can then add it to the structure.

This will be run on large amounts of complex code, so it needs to be versatile. Please see the attached Vi's

Thanks

Joe

 

 

 

 

Download All
0 Kudos
Message 1 of 7
(2,706 Views)

Here's the attached Vis in picture form:

Reference.png

Scripting VI.png

0 Kudos
Message 2 of 7
(2,703 Views)
Solution
Accepted by topic author LVJoe

I would make the following changes:

 

controlrefscripting.png

 

  • You'll want to use the "Move" method, which allows you to specify an Owner.  In this case, the owner is the diagram that owns the original control reference.
  • You'll want to get the wire connected to the original control reference, and get all its sinks (i.e. non-zero indices in the Terminals array), so you know what to wire the new Control Reference to.  That's why the Connect Wire method is in a For Loop...the original control reference may have been wired to more than one object.

Let me know if you have any further questions.  As far as I know, all the properties/methods I'm using in the code above are available in LabVIEW 8.6.

Message 3 of 7
(2,689 Views)

I'd try the Replace method personally.

 

ReplaceReferences.png

 

My sense is that simply relinking each one to its own control might be enough, but I do not have a buggy VI to test.

0 Kudos
Message 4 of 7
(2,675 Views)

One issue with Replace is that it will sometimes try to preserve settings and flags of the old item in the new item.  It sounded like the OP's issues may have been related to something on the original control references getting corrupted, so I figured a wholesale delete/re-drop might be in order here.

0 Kudos
Message 5 of 7
(2,672 Views)

Probably true.  When I find myself in this situation I usually like to find the minimal change I have to make to fix the bug.  The wagering side of me thinks that relinking alone will suffice as it has cured a few wonky things for me in the past.

0 Kudos
Message 6 of 7
(2,667 Views)

This is perfect thank you.

 

I did try the Owner property but only on a property node and it was read only. But using the move method allows specification of the owner, which is exactly what I needed.

 

Thanks,

 

Joe

0 Kudos
Message 7 of 7
(2,652 Views)