question about find and replace
Scott Rossi
scott at tactilemedia.com
Tue Sep 30 05:49:24 EDT 2008
Recently, Peter Alcibiades wrote:
> How do you pad out a series of numbers with leading zeros? Like for instance
> the series is
>
> .1.
> .2.
> .3.
> .11.
> .42.
> .98.
>
> and you want them to be
>
> .001.
> .002.
> .003.
> .011.
> .042.
> .098.
You can use the format function. For example:
answer format("%03s",1)
will display 001 (the 3 means pad with zeros to 3 places). So if the
decimal points in your number series are intentional, you could make a
function like:
function padNumbers pSeries
repeat for each line tNum in pSeries
put "." & format("%03s",char 2 to -2 of tNum) & "." & cr after newSet
end repeat
return newSet
end padNumbers
Regards,
Scott Rossi
Creative Director
Tactile Media, Multimedia & Design
More information about the use-livecode
mailing list