04-08-2010 11:32 AM
Hi all,
Was hoping someone could make a recommendation on my code. I've got a cluster of numerics that I'm converting to strings so I can concatenate and spit out to a text file. I put 2 probes in, 1 before and 1 after the conversion and can't figure how to get the formatting to follow through.
What you see on probe 4 is what I'd like to see it come out of the function or some other formatting function. I could drop the precision down to 0 on the "Number to fractional string" function and it would spit out what I want for that case. However it won't always be a whole number at probe 4. Some cases will be xyz.x - and if we put that to zero, then we're going to loose that decimal. (almost all values will be decimal).
Essentially, I just need to remove the trailing zeros as is set in the display format properties of each element in the numberic cluster.
Solved! Go to Solution.
04-08-2010 11:56 AM
Hi,
Take a look at the attachment.
Hope it helps,
Paulo
04-08-2010 11:57 AM
I'll draw up an example, but I can tell you now, use the format into string VI. Read the context help on it and it should clear things up. Tip: you can double click it and set all the properties if you aren't familiar with setting string formating with things such as %0.4f etc. Using this function will allow you to get rid of that giant concatenation of strings, with a space constant wired in multiple different places.
Anyways, look into it and I'll try to draw up a short example.
04-08-2010 12:03 PM
Replace the number to decimal string with a format to: It is located in the same spot on the palet
04-08-2010 12:09 PM - edited 04-08-2010 12:11 PM
Here, and you can set the display digits for the indicator by right clicking and choosing "display properties". The dialog shown will come up and you can select that way. You can then, after the for loop, use concatenate string to add carriage returns and whatever is in those case structures, before writing to a file.
04-08-2010 12:46 PM
@aeastet:
Tried swapping that out and looked good...till I used a more realistic value, lets say 111.1
That drops the decimal entirely.
Basically, I have a known number of character places to use up. Each element has room for 4 digits when written to the text file. The values should be passed like this:
Numeric --> String
1000 --> 1000
1001 --> 1001
1 --> 1.000
1.001 --> 1.001
12.12 --> 12.12
12.1234 -->12.12
etc.
04-08-2010 01:02 PM
@for(imstruck):
Looks like "%#.3f "
Will spit out the response I was trying to get. Thanks for the stepping stone!
04-08-2010 03:08 PM