LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read variable value knowing only name

Solved!
Go to solution

Is there a way to read a variable value from only knowing the label name? I have Labview 11 and am reading a text file with a list of variable labels and trying to read the value without having to create a case structure of hundreds of variables.

0 Kudos
Message 1 of 9
(4,090 Views)

My first answer was going to be "No", but then I started to think about it.  I'm assuming that the Variables are controls or indicators that are part of the VI or Project of interest.  You could do the following (but it could get messy) --

 

  1. Use the AllVIs property of the current Application to get an array of all VI names in memory.
  2. For each VI name, get a VI Reference, use that to get a Front Panel Reference (property), use that to get Controls[] (property).
  3. For each Control, get its Label (property).  At this point, I think I'd make two arrays, one of the Control References, the other of the Labels.
  4. Once your arrays are built, you can use the Array functions to find the index of the variable you want in the Labels array, and use that index to pull the Value out using the appropriate indexed Control Reference.  Note that this doesn't tell you the "Type" of the variable -- this will be left as an Exercise to the Reader.

Let me know if this works, and is worth the effort.

 

BS

Message 2 of 9
(4,073 Views)

In addition to what Bob Schor described it is important to note:

 

1. A variable in LabVIEW is the wire. A control or indicator is only used to get values from or display them to the user.  Many variables are not connected to controls or indicators at all.

2. For Bob's method to work all controls must have unique names (labels). This is good practice anyway but is not mandatory. If you have five controls named "My Data", how would you know which one had the data you wanted?

 

Have you looked at the Configuration File VIs? They may be able to do much of what you want.

 

Lynn

Message 3 of 9
(4,062 Views)

Bob

 

I don't seem to have an AllVIs property.

 

Jack

 

0 Kudos
Message 4 of 9
(4,044 Views)

Along with Bob and Lynn I offer the following example:

Example_VI.png

in the string you can ignore "Null, FormFeed, @, Newline"- just odd reprentations of size (0x000C) and unmasked Type Code (0x400A)


"Should be" isn't "Is" -Jay
Message 5 of 9
(4,037 Views)
Solution
Accepted by topic author JackTK

Is this what we're wanting?

Example.jpg

Message 6 of 9
(4,027 Views)

@JackTK wrote:

Is there a way to read a variable value from only knowing the label name? I have Labview 11 and am reading a text file with a list of variable labels and trying to read the value without having to create a case structure of hundreds of variables.


When you say variable do you mean a single process variable, a network shared variable, a Global Variable, or are do you mean indicators on a front panel of a vi?    

 

I assume you mean indicators and the code listed in post above should get you started.  If you mean another type of variable then there are other ways to go about it.  

0 Kudos
Message 7 of 9
(4,022 Views)

Thanks DailyDose

 

This solution will work great. I'm sure Bob was trying to get me to do this too.

 

Jack

0 Kudos
Message 8 of 9
(4,004 Views)

Sorry, I was speaking "shorthand".  If you drop a Property Node and don't wire it, it becomes an Application Property Node.  One set of properties are the Application properties, and one of these is AllVIs.  Here is 1000 words:All VIs.png

 

BS

0 Kudos
Message 9 of 9
(3,972 Views)