LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Control Reference Error 1055 when using a for loop

Solved!
Go to solution

Hello,

 

I am having a problem using control references to achieve the following: I have a VI that reads in some data from a text file, and then uses that to automatically update the value of a front panel control on two different VIs, then set the values to default and and save them. From the array of control references, I wanted to loop over the text labels until I get the one matching the control I want to change, and then update its value. The problem I have is that if I use a for-loop, then 9times out of 10 LabVIEW complains of Error 1055: "LabVIEW:  Object reference is invalid". If instead I wire in index array and manually extract the reference, then it works everytime, and for every index of the control reference.

 

Can someone take a look over my code and just see if its obvious what the problem is? In this case I have a simple solution, but I would really like to understand what I have done wrong. I included it as a snippet, but also attached the files if that helps (Its Import_Colormap.vi that is the problem). The disabled code fails, the active code works but I can't see what the difference between them really is - I can change the array index 0,1,2,3..and no error.

 

Thanks.

 

ControlReference.png

0 Kudos
Message 1 of 5
(2,598 Views)

There's no obvious issue with your For Loop.

What is the Label.Text of the control that produces the error?

0 Kudos
Message 2 of 5
(2,574 Views)
Its "Colormap" so I had initially thought it was a bug in using an equals to compare two strings but if I disable the write value in the for loop, it finds only the correct label on the boolean logic and if I wire 0 into my index by array outside the loop it works without a problem (correct label is index 1). I even tried disabling tunnel indexing on the control array and manually indexing using the loop i but that errored too. Also, incase its relevant, this happened on two different machines (xp & os x) running 2012
0 Kudos
Message 3 of 5
(2,562 Views)
Solution
Accepted by topic author jdpritchard

Your "Colormap.ctl" is a strict type def that contains a ring.  You are setting the items programmatically, make the current values default and then save the "Colormap.ctl"?   I have never been practicing this but here is a thread that discusses doing so in detail. I do not understand what you expect to achieve by doing so at run-time.
Next thing: At the same time (in parallel!) you open the Colormap.vi (that is what we can see in yout PNG) which has an instance of the Colormap.ctl on the front panel. I am pretty unsure if LabVIEW can handle this correctly. This might be the reason why you sometimes get the error 1105.
I prefer setting StringsAndValues and subsequently the value for the ring at run-time.  There is no need to do it with a strict type def.

Message 4 of 5
(2,551 Views)
Thanks for the feedback Guenter, I hadn't really considered the fact the control was in the vi, I guess when editing the strict type def normally labview freezes access to all vis containing the control, clearly it would be better to do this sequentially not in parallel!

The idea is that this import vi is run in isolation to update the range of colormaps supported by colormap.vi : the colormap vi is embedded in a number of bigger applications so the benefit of the strict type def on colormap.ctl is all the other vis are updated automatically anytime I add a new colormap. In this case I could just have done it manually but wanted to make it a bit more future proof, and also to learn something new.
0 Kudos
Message 5 of 5
(2,546 Views)