lost zero with add

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
margarinov
Posts: 2
Joined: Thu Feb 07, 2019 4:22 pm

lost zero with add

Post by margarinov » Thu Feb 07, 2019 4:34 pm

I have some field with 00001. When i put it in variable all is fine. But when i make increment (add 1 e t c)zero in left part lost. Of course i can put count of zero in some variable and restore after increment. But maybe having better solution?

Klaus
Posts: 14196
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: lost zero with add

Post by Klaus » Thu Feb 07, 2019 4:40 pm

Hi margarinow,

welcome to the forum!

You need to tell LC to keep the trailing ZERO by setting "the numberformat" before doing the math:

Code: Select all

...
## Set to number of desired digits like this (5 digits, like in your example)
set numberformat to "xxxxx"
add 1 to fld "your field here"
...
Best

Klaus

P.S.
A little "Hello" or something is never a bad idea for the first posting.

margarinov
Posts: 2
Joined: Thu Feb 07, 2019 4:22 pm

Re: lost zero with add

Post by margarinov » Thu Feb 07, 2019 4:49 pm

Thanks for help, Klaus!

I'm new in Livecode sorry for simple mistake.
And of course hi for all.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10320
Joined: Wed May 06, 2009 2:28 pm

Re: lost zero with add

Post by dunbarx » Thu Feb 07, 2019 4:53 pm

Hi.

What Klaus said.

But do read the dictionary entry for "numberFormat". It is important to know that many formatting issues require that at least one mathematical operation be run before the format will be applied.

Craig Newman

Klaus
Posts: 14196
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: lost zero with add

Post by Klaus » Thu Feb 07, 2019 4:54 pm

Well knowing to set "the numberformat" is not really the most simple thing in LC! :D

Post Reply