LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to make a reference of a instrument handle

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

 

 

 

 

Screenshot 2025-04-19 174517.pngScreenshot 2025-04-19 174619.png

0 Kudos
Message 1 of 6
(171 Views)

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.

Santhosh
Soliton Technologies

New to the forum? Please read community guidelines and how to ask smart questions

Only two ways to appreciate someone who spent their free time to reply/answer your question - give them Kudos or mark their reply as the answer/solution.

Finding it hard to source NI hardware? Try NI Trading Post
0 Kudos
Message 2 of 6
(162 Views)

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

0 Kudos
Message 3 of 6
(123 Views)

What do you mean by create the reference

0 Kudos
Message 4 of 6
(81 Views)

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

0 Kudos
Message 5 of 6
(61 Views)

Quick example, i hope it helps.

Yamaeda_1-1745312305020.png

 

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

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 6 of 6
(47 Views)