Numberformat

David Bovill david at openpartnership.net
Tue Aug 26 16:20:52 EDT 2008


2008/8/26 Mark Smith <lists at futilism.com>

> The docs say "It affects numbers only when they are calculated and then
> displayed or used as strings."
>
> I found that if you use <put item 1 of someNum + 0 into word 1 of padedNum>
>
> this forces padedNum to be a string, and you get '08'
>
> I've always found the numberFormat thing confusing, so I always use
> 'format' in these cases...


Hi mark -  I'm moving over  a date function to use "format" - but in the
docs I could not figure how to make it add trailing zeros? "%2d" did not
seem to work:

        if extended is true then
            -- 1981-04-05T14:30:30-05:00
            put "%4s-%2s-%2sT%2s:%2s:%2s-%4s" into baseString
        else
            -- 19810405T14:30:30-05 00
            put "%4s%2s%2sT%2s:%2s:%2s %4s" into baseString
        end if

        put format(baseString, y, mons, d, h, mins, s, z) into fDate

 What should I usee?



More information about the use-livecode mailing list