LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unexepcted results from sub-vi using local variables in LV2009 makes me wonder. What is a local variable really?

Maybe I should also point out that the arrays of constants are only used here to simplify. For real I use variable arrays that cannot be determined at design time and by that folded. It still behaves the same, giving "insane" value.

But if I change the place of the output terminal (ModeName) in the sub-vi to outside the loop and use "shift register" in the for-loop, as suggested by "tst", it's "OK" again, which might be the best way to do it, considering my "fix list" above. To bad it means more wires to clutter the code with, specially since I sometimes have several output terminal this way.

 

But still I'm not completely happy about this change from LV 8.5 since when you consider the for-loop of the sub-vi you might think you know what the output must be...

 

Is it possible it would be considered a bug so it might be fixed in a future patch?

 

0 Kudos
Message 11 of 18
(1,350 Views)

user 4342726352435 wrote:

Is it possible it would be considered a bug so it might be fixed in a future patch?


It definitely is a bug somewhere, which will probably be fixed, but you shouldn't expect to see that fix before the next version of LV, which comes out in August. As you've concluded, using a shift register to pass the value to the terminal outside the loop is the best solution, even if it does complicate the diagram.


___________________
Try to take over the world!
0 Kudos
Message 12 of 18
(1,337 Views)

This thing really drove me nuts Smiley Mad for a couple of days until I found this piece hiding in the dark. To bad there might be more to look for in all my projects...

Thanks a lot for your advice.

0 Kudos
Message 13 of 18
(1,309 Views)
I guess someone has already answered ... but:
The boolean array is only 2 items long, causing the for-loop to run twice, thus "Insane" is the last ModeName generated.

/Y
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 14 of 18
(1,284 Views)

Yamaeda wrote:
I guess someone has already answered ... but:
The boolean array is only 2 items long, causing the for-loop to run twice, thus "Insane" is the last ModeName generated.

/Y

 

 

 

... but the terminal is in the true case...

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 15 of 18
(1,279 Views)
Unless there's a Local Variable in the false case it cant (shouldn't) happen. 😉

One solution is ofc to cluster up the values before feeding them to the loop, cant guarantee it'll make a difference though.

Congrats, you've found a bug! 😄

/Y
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 16 of 18
(1,268 Views)

Just to clarify Yamaeda, since you might not be able to run LV2009 and test mine or tst's code: 

The different lengths of the two constant arrays are not part of the problem. I put an extra element in the string array intentionally to further investigate the "insanity". I thought since the case structure doesn't do it's job properly (stopping the assignment to the output element) maybe the for-loop is crazy too and runs to the end of any data disregarding all rules. But it works fine. The for-loop only runs to the end of the shortest array.

 

There is no object hidden in the pictures, i.e. no local variable in the false case. What you see is all there is.

0 Kudos
Message 17 of 18
(1,225 Views)

Hi

 

I get the same behavior, very weird. One thing that can help you if you are concerned about having to go through all your 8.5 code is mass compile. I tried it (2009 SP1) on the VIs and the answer now comes out OK without any of the fixes you specified in your first post. I completely agree with tst that the shift register and terminal outside the structure is a better solution, this is just a quick fix. I'm sending the VIs to R&D for a look. Will try to keep you posted.

 

Best Regards

 

David

NISW

0 Kudos
Message 18 of 18
(1,146 Views)