From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can Format into String convert to uppercase?

hi everyone!

i use the format into string function quite a lot,
and sometimes i wish i could get some string input out as uppercase/lowercase.

i have read through the help (the format specifier page too) but couldn't find anything.

 

so the chance is slim, but maybe there is?

 

regards & thx for your time!

 

EDIT: to clarify, i mean the text of an enum, which is converted to string with "%s".

 

 


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 1 of 9
(4,163 Views)

I am not aware of anything.  Just use the To Uppercase or the To Lowercase function after your Format Into String.  This might be a good opportunity for a malleable VI.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 9
(4,147 Views)

thx crossrulz

but i see i have miscommunicated my intention/wish,

of course the whole format string is more complicated and the inputs are many,

it would be nice to have a specific portion in uppercase:

e.g. "%s blabla %s blabla %d" and then only the middle %s in uppercase, and the rest as is


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 3 of 9
(4,133 Views)

Like this?

 

snip.png

Message 4 of 9
(4,129 Views)

hi RamonG,

unfortunately this will not work for an enum input 😞

EDIT: i know that i can change before and after, but i wanted the 'format into string' function to do that

but thx for your suggestion anyways!


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 5 of 9
(4,126 Views)

One of the "tricky" parts of Capitalization is whether you want ALL CAPS or what is often called Proper case (where only the first letter of the string is capitalized).  OpenG has such a function (they also have CamelCase,WhereEachFirstLetterIsCapitalizedAndSpacesAreRemoved), and it would be easy enough to write one for yourself.  

 

If the Enum you are trying to Format Into String is one you have defined, then just go and capitalize the items as you wish.  If, however, it is buried somewhere in VILib or some other Library, you can always format the Enum separately and then change the case of the String.  Yes, it is messy, but think of how many "edge cases" you'd need to worry about (see first paragraph).  Nothing is Perfect, but LabVIEW's choices are "pretty good" ...

 

Bob Schor

Message 6 of 9
(4,112 Views)

hi bob,

thx for your answer, also not what i was hoping for ...

but i knew it was a long shot.

 

so i will not mark as solved, but spread a round of kudos.

 

regards


If Tetris has taught me anything, it's errors pile up and accomplishments disappear.
0 Kudos
Message 7 of 9
(4,109 Views)

Changing the case of a formatted enum string sounds like a really bad idea. What if the enum contains upper- and lower case versions of the same string as separate items?

 

What is the purpose of all this? Just cosmetic?

Message 8 of 9
(4,081 Views)

@altenbach wrote:

Changing the case of a formatted enum string sounds like a really bad idea. What if the enum contains upper- and lower case versions of the same string as separate items?


Having upper and lower case versions of the same item within an enum sounds like a far worse problem!

 

@jwscs, I would go with @RamonG's suggestion but use a malleable VI to handle the enum to string to upper case string conversion. I've attached a quick and dirty one but it doesn't do any type or error checking. Note you'll need LV2017+ to use malleable VIs.




Certified LabVIEW Architect
Unless otherwise stated, all code snippets and examples provided
by me are "as is", and are free to use and modify without attribution.
Message 9 of 9
(4,055 Views)