Re: Generate 001,002... name increments
Posted by dscho on Aug 30, 2007; 10:46am
URL: http://imagej.273.s1.nabble.com/Generate-001-002-name-increments-tp3698075p3698081.html
Hi,
On Thu, 30 Aug 2007, Christophe Leterrier wrote:
> Is there a simple way to generate a name suffix with beginning zeros
> like 01,02,03...10,11,12...99 ? I could write a function to transform
> index number into zero-containing suffixes, but I'm wondering if iy
> already exists in the macro language or in Java.
>
> If it does'nt exist, maybe this function could be added to the decimal
> to string d2s() function by adding a second argumnt that specifies the
> number of figures before the coma (the other decimal argument specifying
> the number of decimals after the coma).
function d2s(number, width, character) {
number = toString(number); // force string
character = toString(character);
for (len = lengthOf(number); len < width; len++)
number = character + number;
return number;
}
Hth,
Dscho