LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Local Variable Does NOT get Updated?

Solved!
Go to solution

Hi RavenFan,

 

My plotting code works perfectly well as a stand alone code. If you open my zipped file, it is called "Plotting VI Stand Alone.vi".

By running the code, the user is prompted to select any number of files (from 1 to 13 by holding ctrl down) and it makes two XY plots. One is Y vs. X, the other is Y vs. X with Y error bars.

I have included in the zipped file 13 simple data files that you can try. The error bars come out exactly as I want them. The error bars on each curve match the color of the corresponding curve.

 

Now, I took my stand alone code and made it into a sub VI. This is called "Plotting VI As SubVI.vi" in my zipped file attached below. I call this sub VI in my "Main VI.vi" and when I run

it, it works fine with 1 to 2 files, maybe 3 or 4, but then when you select 7 or 8 files, all of a suddent I get 1077 error and the error bars don't come out right. The colors don't match.

 

Why is this happening?

0 Kudos
Message 21 of 27
(1,087 Views)

Your upper graph only has 13 plots defined, but if you select more than 7 traces at once, you will have more than than and the active plots cannot be found. By the time you call the subVI, these don't exist. Once you have more plots than currently actually exist, you'll get an error. The second time you run it with the same number, the error no longer occurs.

 

Simplest would be to plot dummy data with the correct number of plots to a local variable before calling the subVI, for example.

0 Kudos
Message 22 of 27
(1,063 Views)
Solution
Accepted by topic author murchak

Try something like this. There are probably other solutions...

 

Both of your plots seem to have 13 plots by default, so the error does not occur for less than seven plots. Another possibility would be to pick a higher upper default limit and save the VI. Still, you never know how many plots there will be.

 

Message 23 of 27
(1,055 Views)

Alternatively, you could write the data to a value property of the graph inside the subVI (you already have the reference) before each inner loop. This way you don't even need the outputs of the subVI. 😄

0 Kudos
Message 24 of 27
(1,040 Views)

Thank you very much Altenbach!

 

However, I am not understaning fully why the upper graph has only 13 graphs defined. This is just the number of elements in the point style array that determines the loop iteration count.

You suggestion solved the problem, but I don't know exactly what it did. Thanks a bunch anyway!!

0 Kudos
Message 25 of 27
(1,027 Views)

If you select 13 files, the property loop for the upper graph will iterate 26 times, because all autoindexing input arrays are 2x concatenated versions of the arrays for the other graph. When this happens the first time, the graph still contains a smaller number of plots, so the properties cannot be applied.

 

(This is a somewhat annoying behavior and I intend to post an idea in the ideas exchange how this could be improved. Stay tuned.)

 

 

0 Kudos
Message 26 of 27
(1,021 Views)

@altenbach wrote:

I(This is a somewhat annoying behavior and I intend to post an idea in the ideas exchange how this could be improved. Stay tuned.)


New idea here! 😄

0 Kudos
Message 27 of 27
(1,009 Views)