on 03-19-2007 8:32 PM
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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dave,
Are you trying to format the an Output sting? If so, how are you displaying the data?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
10 | |
5 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.