Remove Zero Padding

Get help using Construct 2

Post » Fri Nov 15, 2013 10:57 pm

Hi guys,

I have a number that I'm storing that is padded with 5 zeros, e.g. "00045". What I'm trying to do now is remove the padding so that I have "45".

I'm not sure what the best way to go about doing it is. Here's what I'm thinking: the logic would be to look at the string and find the position of the first non-zero character and then return a substring from the first non-zero character index to the string length.

I'm having trouble actually writing out the logic in C2 to accomplish this. Any advice?

Thanks!
B
19
S
6
G
2
Posts: 57
Reputation: 2,524

Post » Fri Nov 15, 2013 11:00 pm

Just convert it to int: int("00045")
ImageImageImage
B
71
S
21
G
233
Posts: 3,696
Reputation: 130,368

Post » Fri Nov 15, 2013 11:06 pm

Aaahhhh! I was searching for a way to cast a variable but couldn't find anything.

Thanks a lot!
B
19
S
6
G
2
Posts: 57
Reputation: 2,524


Return to How do I....?

Who is online

Users browsing this forum: David181 and 28 guests