Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

adding a padding to serial string


rawon87 Nov 14, 2019 10:45 AM

Dear fellow users,

is there a way to take a string in variable and add "0" as padding with maximum number of "0"?

for example

wind_speed value is 1.6  i need to add padding (max 5 char for wind_speed) so it will result in 001.6 

i think i can use sprintf, but i'm confused by the example on the crbasic editor help menu

please help


JDavis Nov 14, 2019 11:30 PM

Try this format string.

"%05.01f"

That has both leading zeroes and a trailing 0 if needed.


rawon87 Nov 15, 2019 05:00 PM

Thanks JDavis, i managed to modify it and it works like a charm now

Log in or register to post/reply in the forum.