04-19-2025 05:48 PM
Hello , as I am learning labview I am now finding ways to make my code more structured and readable. Instead of having one big for loop. I am trying to use case structures but I do not know how to send instrument handle from one different case structure to another . I know I am supposed to create a local variable or something of that sort but I can not seem to do it .
Attached are two pictures from two different case structures that I want all to share the same instrument handle but I cannot do it. Please help
04-19-2025 06:27 PM
You use shift registers to pass it across loop iterations and pass the reference in and out of the case structure back to the loop's shift register.
04-20-2025 10:40 AM
A Case Structure "almost always" is "inside" of a Loop-like Structure, such as a While, For, or Event structure. The Reference wire should go into the Loop Structure, usually as a "tunnel" (since it is a Reference, and won't be changing from one Loop to the next) -- this assume you create the Reference before entering the Loop Structure, and destroy it after you exit, otherwise you should use a Shift Register which lets you create the Reference in the first Case (usually an "Initialize" Case) that uses the Reference, and lets you "destroy" the Reference in the last Case (usually an "Exit" Case) that uses it. Note that it is helpful when you are doing something like making "named Choices" (other than "True" vs "False") to name the Cases (like "Initialize", "Use", "Do FFT", and "Exit", which can be done in LabVIEW by either making them Strings (but then you need to be careful to spell the Case "selector", and have a "Default" case that catches your asking to "Do fft", which won't match "Do FFT") -- most "better" LabVIEW Developers use an "Enum" (look on the Front Panel for this) which we "name" and which don't need a "Default" case, but one Case for every Enum value you declare.
Bob Schor
04-21-2025 12:08 PM
What do you mean by create the reference
04-21-2025 08:53 PM
It would be so much easier to provide help and illustrations if you included actual LabVIEW code (this means a file with the extension .vi). It should be small (only having less than a dozen functions/structures/wires etc.) and, because many of the best of us are not using LabVIEW 2025, should be saved using the "Save for previous version" option and something like "LabVIEW 2019" or "LabVIEW 2021" chosen (unless you are using an even earlier version, which is also OK).
If you post your own code, you might even be able to answer the question you asked ("What do you mean by create the reference") yourself -- look for a "fancy wire" that seems to go in and out on the top corners of a number of related VIs, like DAQmx or RGT functions.
Bob Schor
04-22-2025 03:58 AM
Quick example, i hope it helps.