LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Variant to String problem



Ravens Fan wrote:
I'm glad you got it figured out.Smiley Happy  With your later descriptions, what you are doing makes more sense than the way I was interpreting the original post.
 
Out of curiosity, which LV version are you using?  What is the function in your picture that looks like a piece of paper and has the file path going into it?  I hadn't seen that one before.  Is it a LV subVI or a subVI you made?  I'm wondering if it is an older version of a config file VI.


Hi Ravens,
I am using LV 8.5. And that funtion is my own subVI. It retrieves keys and values from that path. With two indexes can be pointed section and key.It also has one output that shows how many keys are in that section, and one shows hows many sections are in that file.
 
Mika
0 Kudos
Message 11 of 21
(4,422 Views)


smercurio_fc wrote:
You might be able to glean the datatype information using the Variant to Flattened String function and looking at the type string output. The information is based on LabVIEW 7, but it might work.



Hi Smercurio,

I did try that one too. It didn't work. The result was that string coming out was empty. Smiley Surprised

Mika

0 Kudos
Message 12 of 21
(4,419 Views)


Wiebe@CARYA wrote:
Mika,

You need to convert it to the correct data type. This is a bit problematic,
since you might not now the type. You need to convert the variant to string,
if that results in an error, convert it to int, if error, try boolean, etc
(order is arbitrary, put the most used first for speed).

Unfortunatelly, there is still no way to get the string displayed in the
variant control in LabVIEW... Perhaps there are some OpenG tools, or perhaps
something on LAVA... I'd give it a shot before trying it myself. If you're
lucky, you might even find some "variant to ini file" functions.

Regards,

Wiebe.





Hi Wiebe
In my application I copy keys from one reference file to another file. Keys are copied one by one. Key values in reference file are indifferent because key values to new file are fetched from shared values. So I put a little hint in reference files key values, like B=Boolean, and then with case structure open shared variable knowing which type variable is going to be.
 
I tried to find that toolkit that could be useful in OpenG pages. I couldn't manage. Somehow I feel search-function is a bit clumsy at OpenG pages.
 
 
Mika
0 Kudos
Message 13 of 21
(4,418 Views)
Hi Smercurio,

I did try that one too. It didn't work. The result was that string coming out was empty. Smiley Surprised


The type string output is the array of integers, not the string output, which is data string.



Message Edited by smercurio_fc on 04-17-2008 09:07 AM
0 Kudos
Message 14 of 21
(4,395 Views)


smercurio_fc wrote:
Hi Smercurio,

I did try that one too. It didn't work. The result was that string coming out was empty. Smiley Surprised


The type string output is the array of integers, not the string output, which is data string.



Message Edited by smercurio_fc on 04-17-2008 09:07 AM


Hi again,

I connected my variant that way. Type string has values 4 and 3, no matter what data type the variable is. I tried that with boolean,double and string variables.

Mika

0 Kudos
Message 15 of 21
(4,379 Views)
If you know the data type (using name hints is a good way to do that), you
can simply use a case to parse the variant to the known type. In the same
case convert the type to string. Put it in a VI that has a variant input
(and a type hint), and a string output.

I'm not sure if there is an OpenG package to do this. But if someone made
something like this, you'll find it on LAVA or OpenG.

Regards,

Wiebe.


0 Kudos
Message 16 of 21
(4,372 Views)

Would the "Get Variant Attribute" Function return what you need?  I think one of the attributes encoded is the original data type?  I have never used it, so I may be way off base.....

 

I see it in 8.5, don't know if it is in earlier versions.....

0 Kudos
Message 17 of 21
(4,355 Views)
OpenG has a tool indeed:

To get some debugging info about variant data have a look at the Variant Browser.
Variant attributes can be used for this, you should write the datatype to an attribute with a clear name eg. 'Datatype'.

Ton


Message Edited by TonP on 04-18-2008 02:25 PM
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 18 of 21
(4,346 Views)
Forgot about that OpenG function. Good tip, Ton.

In fact, if you look at the block diagram, you will see it's using the ... Variant to Flattened String function.  Smiley Wink


That VI in the middle is just parsing the array to get an enumeration.


Message Edited by smercurio_fc on 04-18-2008 09:02 AM
0 Kudos
Message 19 of 21
(4,334 Views)


@KevMi wrote:

I tried to find that toolkit that could be useful in OpenG pages. I couldn't manage. Somehow I feel search-function is a bit clumsy at OpenG pages.
 
Mika


Hello Mika,

Yes, the search capabilities and organization on the OpenG site could certainly be improved.

I think that you might be interested in the OpenG LabVIEW Data Tools library.  It contains VIs for inspecting and operating on variants, type descriptors, and flattened data.

Cheers,

-Jim

0 Kudos
Message 20 of 21
(4,321 Views)