LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Format Into String Bug LV8.6?

I came across something that may be a bug.

 

I am using a Format Into String function in LV8.6.  The attached example is a simplfied version of the string I'm trying to build.  I want to take the input value Address and build it into a zero filled two digit string.  So Address 1 is 01, 2 would be 02, 12 would be 12.  I ultimately found out I wanted %02.0f.  But using the Edit Format String dialog box, I struggled to get there.

 

I right clicked and used Edit Format String.  I selected Pad using zeroes, selected Use field Width and entered 2.  I selected the check box for precision and left the box at the default of zero.  It came up as %2f.  The results weren't what I wanted.

 

I redid the Edit Format String and saw the Precision Check box was unchecked.  Only by explicitly typing in a zero over the zero could I get the Precision Box to remain check and give me a %02.0f string which gave me the result I wanted.

 

See the attached VI.  Right click and do Edit format String.  Uncheck the precision box and say okay.  Then go in and Recheck it and say okay.  You'll see the original setting did not come back.  Going in and looking at it again, you'll see it remain unchecked.

 

Repeat all this but type a zero over the zero in the precision box and all works fine.

 

Playing around a bit more, I think the Field width box does a similar thing.  Check the box, but don't change it from zero to zero, the box unchecks.  (although I'm not sure what a minimum field width of zero really means, whether that is a logical use.)  But if you do type a zero over a zero on the minimum width box, it still unchecks.

 

Bug?

Message Edited by Ravens Fan on 03-24-2009 05:24 PM
0 Kudos
Message 1 of 4
(2,455 Views)

I think you need the %02d specifier, but that is not your problem.

 

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!
Message 2 of 4
(2,439 Views)
Definitely a bug, and here's what's going on:  The dialog box expects you to enter a number when you check the precision check box.  You'll note that if you check the box, the 0 is highlighted.  If you press OK, the string doesn't get updated.  If you check the box, then type in 0 and press OK (You don't have to click anywhere), you will see the string update.  The code must be looking for the value to be changed to actually update the string instead of forcing an update of the string when you check the box, then updating again when you change the value.
Message 3 of 4
(2,434 Views)

TonP wrote:

I think you need the %02d specifier, but that is not your problem.

 

Ton


 

Thanks Ton,

 

I should be using %02d instead, and I'll change my code to that.  I can never remember all the details of creating the format specifier, so I like to use the dialog box to structure it for me.  I also always have a hard time finding the format specifiers in help.  They always seem to be scattered between different help screens for format into string, and scan from string, perhaps elsewhere.  I usually use the dialog.  Try it out.  Modifier the code in some simple ways.  Only if I still can't figure it out do I go to help.

 

Using the Format string dialog, it had started with the %f and I worked from there and got it to give me the result I wanted completely forgetting about the %d type.  But in the process stumbled over what I think is a bug.

 

Matthew,  Thanks for trying out the steps as well and agreeing with me that there seems to be a bug in this dialog box.

0 Kudos
Message 4 of 4
(2,419 Views)