<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Get variable name and type dynamically in LabVIEW</title>
    <link>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519562#M246773</link>
    <description>Here are a couple other previous posts that may be of interest:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.ni.com/ni/board/message?board.id=170&amp;amp;message.id=222324&amp;amp;requireLogin=False" target="_blank"&gt;http://forums.ni.com/ni/board/message?board.id=170&amp;amp;message.id=222324&amp;amp;requireLogin=False&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.ni.com/ni/board/message?board.id=170&amp;amp;message.id=241608&amp;amp;requireLogin=False" target="_blank"&gt;http://forums.ni.com/ni/board/message?board.id=170&amp;amp;message.id=241608&amp;amp;requireLogin=False&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.ni.com/ni/board/message?board.id=170&amp;amp;message.id=78012&amp;amp;requireLogin=False" target="_blank"&gt;http://forums.ni.com/ni/board/message?board.id=170&amp;amp;message.id=78012&amp;amp;requireLogin=False&lt;/A&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
    <pubDate>Thu, 10 May 2007 16:31:50 GMT</pubDate>
    <dc:creator>Doug M</dc:creator>
    <dc:date>2007-05-10T16:31:50Z</dc:date>
    <item>
      <title>Get variable name and type dynamically</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519018#M246582</link>
      <description>&lt;SPAN class="noindex"&gt;
   Hi all,&lt;BR /&gt;&lt;BR /&gt;What I am trying to do is be
able to read the name (label) and type of a variable.&amp;nbsp; Here is a simple
example of what I want to do:&lt;BR /&gt;&lt;BR /&gt;1.&amp;nbsp; Main VI calls a sub VI, data is passed to the sub VI in a cluster.&lt;BR /&gt;2.&amp;nbsp; Cluster contains four elements: a boolean, a string, a double, and an integer.&lt;BR /&gt;3.&amp;nbsp;
The sub VI should take this input cluster, read the name of each
element, concatenate each of those into one string (tab delimited).&lt;BR /&gt;4.&amp;nbsp;
The sub VI should also read the type of each element, and be able to
use this type to decide on a format string to use when converting the
element's value to a string.&lt;BR /&gt;&lt;BR /&gt;I can do all of the programming
above except for being able to read the type and name of any given
element of the input cluster.&amp;nbsp; I know you can use a property node to
get these data if you were trying to do so for a front panel control,
but can you do this for a variable that has been passed into a sub VI
using a cluster?&amp;nbsp; Also, my example is simple; I have about 50 different
inputs I want to perform this operation on.&amp;nbsp; Thanks in advance for any
help you can give to me.&lt;BR /&gt;&lt;BR /&gt;-Ian&lt;/SPAN&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 09 May 2007 22:18:32 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519018#M246582</guid>
      <dc:creator>ishieh</dc:creator>
      <dc:date>2007-05-09T22:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable name and type dynamically</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519025#M246584</link>
      <description>You basically use control reference to do this sort of this, as shown in the attached sample. There may be an easier way to do what you're looking to do. When you say you want to convert it to a string, is this supposed to be a flattened string of the value, or a human-readable formatted string? If it's a flattened string you can just flatten to string the cluster control directly.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 09 May 2007 22:30:49 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519025#M246584</guid>
      <dc:creator>smercurio_fc</dc:creator>
      <dc:date>2007-05-09T22:30:49Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable name and type dynamically</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519027#M246585</link>
      <description>smercurio_fc,&lt;BR /&gt;&lt;BR /&gt;Thank you for the reply, but unfortunately I am running LabVIEW 8.0.1 so I can't load your examples, is there a way you could convert it to my older version or just post a screenshot?&amp;nbsp; Also, to answer your question about the string, I want a human readable string, basically it needs to be written to a text file.&amp;nbsp; Thanks for your help.&lt;BR /&gt;&lt;BR /&gt;-Ian&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 09 May 2007 22:34:55 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519027#M246585</guid>
      <dc:creator>ishieh</dc:creator>
      <dc:date>2007-05-09T22:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable name and type dynamically</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519149#M246615</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;Maybe you can rty something like this.</description>
      <pubDate>Thu, 10 May 2007 04:55:01 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519149#M246615</guid>
      <dc:creator>parthabe</dc:creator>
      <dc:date>2007-05-10T04:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable name and type dynamically</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519485#M246742</link>
      <description>Unfortunately Partha, that suggestion doesn't answer the question, since that provides flattened data, and Ian wants human-readable strings. Also, it employs the use of an unsupported "scripting" function, as evidenced by the red property node. &lt;BR /&gt;&lt;BR /&gt;I would suggest heading over to open.org and downloading their VI Package Manager. This will allow you to download individual OpenG libraries. The one you want is the OpenG Variant package. You may need to download others due to dependency, but the VI Package Manager will inform you of this. It's got VIs in there that will allow you to write clusters to INI-file formatted structure. No fuss, no muss. I think this may be a better solution for you.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 10 May 2007 14:47:39 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519485#M246742</guid>
      <dc:creator>smercurio_fc</dc:creator>
      <dc:date>2007-05-10T14:47:39Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable name and type dynamically</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519562#M246773</link>
      <description>Here are a couple other previous posts that may be of interest:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.ni.com/ni/board/message?board.id=170&amp;amp;message.id=222324&amp;amp;requireLogin=False" target="_blank"&gt;http://forums.ni.com/ni/board/message?board.id=170&amp;amp;message.id=222324&amp;amp;requireLogin=False&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.ni.com/ni/board/message?board.id=170&amp;amp;message.id=241608&amp;amp;requireLogin=False" target="_blank"&gt;http://forums.ni.com/ni/board/message?board.id=170&amp;amp;message.id=241608&amp;amp;requireLogin=False&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.ni.com/ni/board/message?board.id=170&amp;amp;message.id=78012&amp;amp;requireLogin=False" target="_blank"&gt;http://forums.ni.com/ni/board/message?board.id=170&amp;amp;message.id=78012&amp;amp;requireLogin=False&lt;/A&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 10 May 2007 16:31:50 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519562#M246773</guid>
      <dc:creator>Doug M</dc:creator>
      <dc:date>2007-05-10T16:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable name and type dynamically</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519571#M246778</link>
      <description>Just to follow up with the request that you wanted the VIs in 8.0...&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 10 May 2007 16:46:14 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519571#M246778</guid>
      <dc:creator>smercurio_fc</dc:creator>
      <dc:date>2007-05-10T16:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable name and type dynamically</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519715#M246837</link>
      <description>I appreciate everyone's help; I looked through your examples and other threads and came up with a solution that I think suits my needs best.&amp;nbsp; I've attached it in case someone else might find it useful.&lt;BR /&gt;&lt;BR /&gt;-Ian&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 10 May 2007 21:14:31 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519715#M246837</guid>
      <dc:creator>ishieh</dc:creator>
      <dc:date>2007-05-10T21:14:31Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable name and type dynamically</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519719#M246839</link>
      <description>Something I realized I forgot to mention as a word of caution: the subVI that I used (GetTypeInfo.vi) seems to run very slowly.&amp;nbsp; For my application, I only need to read the label info once (a data file header).&amp;nbsp; I then will write the values of the variables many times (thousands of times per experiment).&amp;nbsp; However, since finding the data type of the variants is relatively slow, I only do so the first time I am reading in data from the cluster.&amp;nbsp; I can then store the data types in an array to be used on subsequent calls to this data file writing VI.&amp;nbsp; The time savings of this setup is significant.&lt;BR /&gt;&lt;BR /&gt;-Ian&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 10 May 2007 21:20:19 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519719#M246839</guid>
      <dc:creator>ishieh</dc:creator>
      <dc:date>2007-05-10T21:20:19Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable name and type dynamically</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519729#M246842</link>
      <description>&amp;lt;Saverio scratches his head for a while and frowns...&amp;gt;&lt;BR /&gt;&lt;BR /&gt;You know, I can't quite figure out why you need to do this. I can see doing this kind of operation if you're trying to save configuration information for a VI front panel or something. That's something that comes up often. But if you're doing it to save data, there's better ways to do it than going through variants the way you're doing. Is the cluster the individual data item that you have, and you have an
array of these? It seems to me that you can save this as a simple table. Why do you need to go through the variants just to get the value? &lt;BR /&gt;Is this intended to be parsed somehow? If so, I can already see a problem. The control labels are delimited by a space. What if the label has a space, as in your example with "Double Float". How do you know where one label ends and the next one begins? &lt;BR /&gt;&lt;BR /&gt;Your initial question was very specific, and based on your last post it seems to me that your overall goal may require a different solution. Do you have an example of the data that you're trying to save and what format you're trying to get to?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 10 May 2007 21:48:56 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519729#M246842</guid>
      <dc:creator>smercurio_fc</dc:creator>
      <dc:date>2007-05-10T21:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable name and type dynamically</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519740#M246849</link>
      <description>Sorry, you are right, I tried to keep the question in my first post direct, but an overall picture would be better.&amp;nbsp; Here is what my overall goal is:&lt;BR /&gt;&lt;BR /&gt;I have my LabVIEW program controlling an experimental setup as well as logging data from it.&amp;nbsp; Right now I have about 15 variables I am recording, but wish to increase this to 30 in the near future, and probably many more in the not so distant future.&amp;nbsp; What my data file is is just a simple text file that is tab delimited so that I can read it easily in Excel.&amp;nbsp; I want a header to be produced that has the variable names, and then in subsequent rows, there are the values of each variable.&amp;nbsp; I record data about twice a second.&lt;BR /&gt;&lt;BR /&gt;The reason I asked my questiona bout the cluster is that I pass my data around my main VI and to my sub VIs in a large cluster.&amp;nbsp; Since I want to have my data logging done in a sub VI, I pass all my variables to it in a cluster.&amp;nbsp; Before, I was manually writing out a header string to be written to a file, and then connecting all my variables to a "Format to String" VI with a very long format string.&amp;nbsp; I just saw this approach getting out of hand whenever I wanted to add or delete a variable to be recorded.&amp;nbsp; I looked at some of the built-in VIs for writing to a spreadsheet file, but they seem to require arrays of all the same data type, which isn't suitable for my application.&lt;BR /&gt;&lt;BR /&gt;I am new to LabVIEW, so I really don't know the most efficient way of doing things, but your help really is appreciated and it helps me learn.&amp;nbsp; I welcome any suggestions for writing my data in a more efficient manner.&amp;nbsp; Also, if I still haven't made my overall goal clear, I can try clarifying it more.&lt;BR /&gt;&lt;BR /&gt;-Ian&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 10 May 2007 22:03:12 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/519740#M246849</guid>
      <dc:creator>ishieh</dc:creator>
      <dc:date>2007-05-10T22:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable name and type dynamically</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/520309#M247047</link>
      <description>OK, now I understand better. It seems you have two issues. The first is that the data you're trying to save isn't all the same data type. The second is that you want something that's not going to be difficult to update in the future should you add/delete data items. The variant route that you took is one way. Another way was your original method, but as you said, those format strings can get pretty cumbersome when long. You can mitigate this by creating a VI that generates the string for you based on your data cluster. Another method is to use the "Flatten to XML" function. This function will flatten anything to a nice XML string. In fact, for you, it generates what you need. You get the labels and the values already formatted. You basically just need to separate out the XML string to get your row of values. As for the header, you don't need to use variants as the detour. You can either use the same "Flatten to XML" method, or use the property nodes. I put together a simple example for you to take a look at. Whether it's faster for you than the variant route you'll need to see for yourself. Note that I made the cluster a typedef. I think you really need to do this for your application so that when you change the cluster you only change it one place.&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 11 May 2007 20:14:21 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/520309#M247047</guid>
      <dc:creator>smercurio_fc</dc:creator>
      <dc:date>2007-05-11T20:14:21Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable name and type dynamically</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/520375#M247066</link>
      <description>smercurio,&lt;BR /&gt;&lt;BR /&gt;I like your idea of using the XML string to get out the value in a string format.&amp;nbsp; You could also use this to get the labels as well, which would be useful in my case, since I do not want to record values from all elements in my cluster, only selected ones.&amp;nbsp; This means reading the label from "all controls" wouldn't get me what I need.&amp;nbsp; I think that I will keep my implementation with variants, since I have that working just fine.&amp;nbsp; I do greatly appreciate you mentioning using a typedef though, as I didn't think of doing so before, and that'll help simplify updates greatly.&amp;nbsp; Thank you again for all your advice.&lt;BR /&gt;&lt;BR /&gt;-Ian&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 11 May 2007 23:15:41 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/520375#M247066</guid>
      <dc:creator>ishieh</dc:creator>
      <dc:date>2007-05-11T23:15:41Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable name and type dynamically</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/520412#M247080</link>
      <description>&lt;DIV&gt;&lt;/DIV&gt;&lt;BR /&gt;
&lt;BLOCKQUOTE&gt;
&lt;HR /&gt;&lt;a href="https://ni.lithium.com/t5/user/viewprofilepage/user-id/33243"&gt;@smercurio_fc&lt;/a&gt; wrote:&lt;BR /&gt;Unfortunately Partha, that suggestion doesn't answer the question, since that provides flattened data, and Ian wants human-readable strings. Also, it employs the use of an unsupported "scripting" function, as evidenced by the red property node. &lt;BR /&gt;
&lt;HR /&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Hi smercurio, I dont understand your statement, it employs the use of an unsupported "scripting" function, as evidenced by the red property node.&lt;/P&gt;
&lt;P&gt;Is it there inside the Vi I attached, or are you telling in general ?&lt;/P&gt;
&lt;P&gt;I cant see these things in my VI. &lt;img id="smileyindifferent" class="emoticon emoticon-smileyindifferent" src="https://ni.lithium.com/i/smilies/16x16_smiley-indifferent.gif" alt="Smiley Indifferent" title="Smiley Indifferent" /&gt;&lt;/P&gt;
&lt;P&gt;Please clarify me reg this. I m using LV 7.1.&lt;/P&gt;</description>
      <pubDate>Sat, 12 May 2007 06:22:26 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/520412#M247080</guid>
      <dc:creator>parthabe</dc:creator>
      <dc:date>2007-05-12T06:22:26Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable name and type dynamically</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/520438#M247091</link>
      <description>There is a misunderstanding here. A red property node indicates a obsolete property/data type. You can see this when you open up a 7.x VI with panel items in 8.x (panels are kind a removed in 8).&lt;BR /&gt;The scripting color is somehting else.&lt;BR /&gt;Now I see why we have yellow and blue bars at the NI forums.&lt;BR /&gt;&lt;BR /&gt;Ton&lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sat, 12 May 2007 15:08:47 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/520438#M247091</guid>
      <dc:creator>TCPlomp</dc:creator>
      <dc:date>2007-05-12T15:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: Get variable name and type dynamically</title>
      <link>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/520881#M247276</link>
      <description>Thanks for the correction, Ton. &lt;BR /&gt;&lt;BR /&gt;My statement regarding the fact that it generates flattened data, which is not what the poster wanted, still stands, though. &lt;BR /&gt;&lt;DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 14 May 2007 14:00:51 GMT</pubDate>
      <guid>https://ni.lithium.com/t5/LabVIEW/Get-variable-name-and-type-dynamically/m-p/520881#M247276</guid>
      <dc:creator>smercurio_fc</dc:creator>
      <dc:date>2007-05-14T14:00:51Z</dc:date>
    </item>
  </channel>
</rss>

