cancel
Showing results for 
Search instead for 
Did you mean: 

String Formatting in Business Logic Editor

Former Member
0 Kudos

I need to left justify a variable length character string (10-15 characters) in a property that will be 20 characters wide. In C, I would use the sprintf format string "%-20s". Is there a comperable format code in xMII?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi, David.

There's not a built-in function for this, but here's a trick I use.

1) Create a Global property called "Spaces", of type "String". Type in about 80 spaces into the dialog.

2) Anywhere you need "padded strings", you can use an expression such as (assuming you have a string "XYZ" in a local property named "Thing":

To left justify:

Local.Thing & stringleft(Globals.Spaces,20-stringlength( Local.Thing))

To right justify:

stringleft(Globals.Spaces,20-stringlength( Local.Thing)) & Local.Thing

That's all it takes! Hopefully it should work well for you.

Best regards,

Rick

Former Member
0 Kudos

Rick-

Great minds think alike. I had actually started on that prior to seeing your post. I did not think to make SPACES a global. I will make that revision.

Thanks

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Dave,

Are you trying to format the an Output sting? If so, how are you displaying the data?