Jump to content

Cluster values to strings


Recommended Posts

Hi all,

Once again I seek the wisdom of those a little more clued up on LV than I am! I have a main VI that runs some automatic tests. On the VI's front panel there are some control clusters, via the elements of which the user enters test condition information prior to running the test (operator name, path loss, test frequency etc., all that kind of stuff). The test results are written to file but I would like to write the test conditions (i.e. the cluster element values) to file as well. So the problem is converting a cluster's elements, which may be mixed data types (but are most likely to be Numeric, String, Path or Boolean), to strings.

I have a VI that I've attched that seems to do the job nicely. However, I look at it and can't help feeling there must be a neater way of doing it. Something using variant data nags away at me but I can't get anything going with that (never been much good using variant data!). One last stipulation, the conversion of a Numeric must result in a string that appears exactly as the number appears in its Numeric control, not any different format.

I'd be interested if any of you have any suggestions. Many thanks.

Regards, Graeme.

Link to comment

If you just want to save this data in a file and retrieve it later, then flattening to an XML format may prove useful.

http://forums.lavag.org/index.php?act=attach&type=post&id=6159

http://forums.lavag.org/index.php?act=attach&type=post&id=6160

QUOTE(Graeme @ Jun 19 2007, 12:31 PM)

One last stipulation, the conversion of a Numeric must result in a string that appears exactly as the number appears in its Numeric control, not any different format.

Using a typedef cluster as I did above, the display format is saved for you in a .ctl file, so you needn't worry about the text file holding the formatting.

Hope this helps

Link to comment

Your approach is correct. The use of variants wouldn't help much since you would still have to retrieve either the format string or the displayed string of each control anyway.

You can take a look at OpenG's "Format Variant into String" that formats a variant scalar input into string. You can specify the format string either at the input or as a variant attribute.

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.