LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I get a variant's string data?

(shucks, thought I had you there Smiley Wink )
As I understand it, that's a pretty interesting idea - kinda like a comment-field that's an attribute of each data-element - but for that, you could use "Set Variant Attribute" to create a "MetaData" (string) attribute that would follow each variant - no?  I haven't used these at all besides a brief experiment just now that appended an attribute called "Comment" to a variant.  If this is on track, see attached!  
 
Cheers.
"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 11 of 22
(2,405 Views)
Really thought this was what was requested - access to the Variant's "Text Box"!
 

Message Edited by tbd on 01-17-2007 09:20 PM

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 12 of 22
(2,380 Views)
Yes, I thought too he was looking for the Variant string (but maybe not)

If not he should have a look at my variant probe which shows how to read variants.
A screenshot:


Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 13 of 22
(2,365 Views)

TBD, your last post is correct - I am looking for the variant's string, which would naturally include all of the varaiant's attributes, as well as the data formats.  The use case goes something like this:

1.  The server application builds up a variant in the normal way, converting data to a variant, and then attaching attributes using Set Attribute.

2.  The server then obtains the variant string, and puts that string into the shared variable description (or what have you).  Variant to String doesn't work becuase it strips out the attributes.  Ditto Flattent ot XML.  The various Flatten to String options don't work because they are not human-readable.

3.  The client application obtains that string, and reinserts it into a variant (not using To Variant, as that will just make a long string with no attributes).

4.  The client then uses the Get Attribute primitive to strip out any attributes of interest.

0 Kudos
Message 14 of 22
(2,342 Views)

Hi Allen,

      First, thank you for your patience! Smiley Happy

      I had some tools left-over from a Database project and threw something together that, I think, serves as an example of what you want.  This isn't to ignore what Altenbach said about the optimal solution being a native/no-code implementation!

It was only after starting this that I realized it's related to something I've been saving as a pet project - a Cluster-to-INI-file converter.  XML just isn't friendly enough!  BTW, to give credit where due, a key routine and data-type used here came from Jim Kring.  Anyway, here goes...

?

Message Edited by tbd on 01-19-2007 01:58 AM

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
Download All
0 Kudos
Message 15 of 22
(2,320 Views)
Thanks, I'll give these a look over and see if they work for my needs.  I'd hoped for a native method but... <shrugs>.
 
I'm entertained that you have a cluster-to-INI utility.  I've put more than a few hours here into a set of routines for just that purpose.
0 Kudos
Message 16 of 22
(2,314 Views)

Hi Allen,

While I'm happy to entertain, I didn't mean to imply that my pet-project actually existed - it was more of a virtual-pet.  Smiley Wink  Maybe Franken-pet would be a better description of parsing arbitrarily complex cluster type-strings (and the re-building of the type would have been worse!). 

The shame of having to admit this drove the effort to develop a real tool - a first-draft of a cluster-to-INI converter that uses LabVIEWs XML tools to do the hard part (decomposition of the Cluster).  An INI to Cluster converter (another virtual pet) will convert INI to XML, then let the XML tool reassemble the cluster.

I have no use for this tool right now, but when the time comes, I'll probably tweak it to make some things a bit nicer.  Like arrays of simple-types don't need to reflect name/type for every element.

Cheers!

Message Edited by Support on 01-24-2007 11:41 AM

"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 17 of 22
(2,285 Views)
I also worked on a tool like this before.

I (in all my innocence and stupidity) worked entirely with Object references and VI server to parse the input cluster.  It was buggy (making sure all the references are properly closed for an arbitrarily complex cluster is a pure nightmare) and the values were written to the ACTUAL Control whose reference was passed to the sub-routine (Via the "Value" property).  This also had the nice side-effect of making the whole thing Veeerrryyy slow.

Still, it worked and I was happy with it until I found the OpenG variant (pun intended).

It's a nice project to learn from, I think I know quite a lot about working with control references now.  It's not likely to surpass the OpenG version though.

Now a scripted INI read routine with an arbitrarily complex cluster where the ACTUAL data type can be recreated as an output.  Just picture it, tell LV "Here's my INI cluster, please read it for me" and then (After probably 10 minutes or so) you have the actual code for reading it.......  Kind of like INImx really 😉

That would be cool.

I think I'll add a product feature request!

Shane
Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)
0 Kudos
Message 18 of 22
(2,279 Views)


@shoneill wrote:
I also worked on a tool like this before.

I (in all my innocence and stupidity) worked entirely with Object references and VI server to parse the input cluster.  It was buggy (making sure all the references are properly closed for an arbitrarily complex cluster is a pure nightmare) and the values were written to the ACTUAL Control whose reference was passed to the sub-routine (Via the "Value" property).  This also had the nice side-effect of making the whole thing Veeerrryyy slow.

Still, it worked and I was happy with it until I found the OpenG variant (pun intended).

It's a nice project to learn from, I think I know quite a lot about working with control references now.  It's not likely to surpass the OpenG version though.

Now a scripted INI read routine with an arbitrarily complex cluster where the ACTUAL data type can be recreated as an output.  Just picture it, tell LV "Here's my INI cluster, please read it for me" and then (After probably 10 minutes or so) you have the actual code for reading it.......  Kind of like INImx really 😉

That would be cool.

I think I'll add a product feature request!

Shane


> Still, it worked and I was happy with it until I found the OpenG variant (pun intended)...

... well it figures OpenG got there first!
 
Part of the fun (for me) IS re-inventing the wheel!  (...and XML and recursion offered a very simple solution.)
I'd offer to do the INI to Cluster converter - which won't be too difficult - but I doubt anyone will be content with the way the INI is rendered (here) in the first place.
 
Cheers.
 
"Inside every large program is a small program struggling to get out." (attributed to Tony Hoare)
0 Kudos
Message 19 of 22
(2,262 Views)
Dear tbob,

          I am trying to do the same thing and want the variant input into numeric and for that i have input the numerical constant at the type input of Variant to data, but after doing this I am getting the error as per below:

"The data type of variant is not compatible with the data type wired to the type input". Can you tell me what could be the error, I have attached the jpeg of the error, with this post, so that you can see what i have coded and what i am getting error.

Thanks,
Nishant
0 Kudos
Message 20 of 22
(2,127 Views)