PDA

View Full Version : Padding variables with spaces/blanks



JerryS@cat
01-23-2023, 11:11 AM
I have searched through the forum and not found anything on this SetupBuilder scripting topic, so here's the question I'm posing.
Is it possible to pad a character string with trailing spaces or blanks? From how I've seen SetupBuilder scripting act, it seems that if there are trailing spaces/blanks in a variable, it truncates them automatically when doing any kind of operation with the variabe, and there doesn't seem to be anything you can do to keep the trailing space(s) in the variable. For example, in this following SetupBuilder script code, I set the values of the first two variables to have a trailing space . . .

Set Variable %OUTPUT_FIELD1% to "SetupBuilder "
Set Variable %OUTPUT_FIELD2% to "is "
Set Variable %OUTPUT_FIELD3% to "awsome!"

Set Variable %OUTPUT_LINE% to %OUTPUT_FIELD1%%OUTPUT_FIELD2%%OUTPUT_FIELD3%

I would expect the content of the %OUTPUT_LINE% variable to have a value of (excluding the quotes) "SetupBuilder is awesome!" . . . but it's doesn't.
Because SetupBuilder is truncating the trailing spaces when it evaluates them and performs an operation on them, the value ends up being "SetupBuilderisawesome!"


If I were to using the same example, only with leading blanks instead of trailing blanks, the results are different. SetupBuilder will keep leading blanks when doing the operations.


Set Variable %OUTPUT_FIELD1% to "SetupBuilder"
Set Variable %OUTPUT_FIELD2% to " is"
Set Variable %OUTPUT_FIELD3% to " awesome!"

Set Variable %OUTPUT_LINE% to %OUTPUT_FIELD1%%%OUTPUT_FIELD2%%OUTPUT_FIELD3%

In the above case, the value of %OUTPUT_LINE% will be "SetupBuilder is awesome!" . . . keeping the leading spaces.

So, my question is why does SetupBuilder seem to automatically truncate trailing spaces when doing operations on character strings, and how can you circumvent that (if possible)?

linder
01-24-2023, 08:33 AM
Hi Jerry,

Good question. I'll have to play with it and get back to you!

Friedrich

JerryS@cat
02-16-2023, 04:19 PM
Hey, Friedrich, it's been about 3 weeks now. Any word on this yet?

linder
02-17-2023, 07:45 AM
Hi Jerry,

in the current SB version it always truncates trailing spaces. In earlier versions of SB, it truncated both leading and trailing spaces. We are experimenting right now in SB 2023 how to change this behavior. But in the current version it is definitely not possible!

Friedrich