LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

[Feature or Bug?] Format Into String Adds Spaces

I happen to really like the Format Into String function, and have almost forsaken concatenate strings in the case of joining simple strings.  One of my favorite features is the automatic generation of the Format String: I can shuffle and add or remove inputs without worrying about changing the Format String.  However, is it a bug or feature that LV will add a space between the different inputs, for example:

 

UnwantedSpace.png

 

Three possibilities (at least):

 

1. Bug : Please fix.

2. Wanted (by most) feature

3. Unwanted (by most) feature

 

I am sure that someone out there relies on this behavior so it is probably entrenched as a feature by now.  In this case I'll probably make a move to suggest an additional input for a default separator.  Space by default, but happy with empty string.  Either that or a Right-click option to add spaces or not.

 

Anybody with a reason why the current behavior makes perfect sense?

0 Kudos
Message 1 of 7
(5,651 Views)

I remember a similar discussion from very long ago (pre-NI forum?)

 

All you need is to actually specify a format, e.g. "%s%s" in this case. The current behavor makes more sense in the case of numbers, e.g. where "1 2" is probably more reasonable than "12" when two consecutive integers are formatted.

 

Message 2 of 7
(5,646 Views)

I was always supprised that the format string is not requires (hiden inside of string format).  This leaves ambiguity in the actual format (ie %s %s instead of %s%s)

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 3 of 7
(5,638 Views)

@altenbach wrote:

 

All you need is to actually specify a format, e.g. "%s%s" in this case.

 



Of course, but then you have to update it every time you add/remove an input.  I hate to specify %s%s%s%s%d%s%s%s%s....

 

In fact, I typically will wire the inputs and then Edit the format string, but instead of being 90% correct as created, the spaces usually means it is only 10% correct.

0 Kudos
Message 4 of 7
(5,630 Views)

Darin.K

 

I looked into this and it is in fact expected behavior, for the reason that altenbach already stated (makes more sense with numbers).

 

If you are just looking to put strings together, it would probably make more sense to use the Concatenate Strings functions.

 

Have a great day,

 

Chris V

Applications Engineer
National Instruments
Message 5 of 7
(5,602 Views)

@Chris V wrote:

Darin.K

 

I looked into this and it is in fact expected behavior, for the reason that altenbach already stated (makes more sense with numbers).

 

If you are just looking to put strings together, it would probably make more sense to use the Concatenate Strings functions.

 



Thanks.  I pretty much assumed it was done on purpose, whether or not it makes more sense depends on your usual applications.  My usual preference is that if I want something (ie. a space) I'll put it in.  Concatenate strings has it use (arrays, for example), but the power of the Format function is the agile handling of multiple types and ease of resizing.  If it would just get the format string "right" I wouldn't have to show that little piece of ugliness on the BD.  The format function plays so well with the Regex functions, except when I go to piece back the string and I get some added spaces.  I'll either stick with my new XNode version which gives me the resizing option as well as separator control, or get around to suggesting that we have that option space/tab/nothing default separator in the native functions.

0 Kudos
Message 6 of 7
(5,591 Views)

If I had a say in this I would require the format string input as required input instead of adding yet another popup-option to a LabVIEW node.

Rolf Kalbermatter
My Blog
0 Kudos
Message 7 of 7
(5,569 Views)