キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

read variable value knowing only name

解決済み
解決策を見る

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 件の賞賛
メッセージ1/9
6,095件の閲覧回数

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

メッセージ2/9
6,078件の閲覧回数

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

メッセージ3/9
6,067件の閲覧回数

Bob

 

I don't seem to have an AllVIs property.

 

Jack

 

0 件の賞賛
メッセージ4/9
6,049件の閲覧回数

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
メッセージ5/9
6,042件の閲覧回数
解決策
受理者 JackTK

Is this what we're wanting?

Example.jpg

メッセージ6/9
6,032件の閲覧回数

@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 件の賞賛
メッセージ7/9
6,027件の閲覧回数

Thanks DailyDose

 

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

 

Jack

0 件の賞賛
メッセージ8/9
6,009件の閲覧回数

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 件の賞賛
メッセージ9/9
5,977件の閲覧回数