[ic] Increment integer with preceding zeros
Grant
emailgrant at gmail.com
Sun Apr 6 12:07:09 CDT 2008
> >> Is there a way to increment an integer like 000001 to end up with
> >> 000002? The integer is stored in a MySQL table.
> >
> >
> > Of course, there's a few different ways. If you give some more details
> > of what you're trying to do, though, it will be easier to give an
> > appropriate answer to your question. Where do you want the increment to
> > occur, and when, etc?
>
> I'll give you a bit of code you can use in perl to do it:
>
> $i = sprintf('%0' . length($i) . 'd', $i + 1);
Thanks a lot everyone. I went with this:
[tmp new_counter][data variables value counter][/tmp]
[perl no_return=1] $Scratch->{new_counter} =
sprintf("%06d",$Scratch->{new_counter} + 1); [/perl]
[data table="variables" field="value" key="counter" value="[scratch
new_counter]"]
- Grant
> Peter
More information about the interchange-users
mailing list