Re: how to get a value

Nikolai Kondrashov <[email protected]> Thu, 20 Aug 2009 21:39:48 +0400
Newsgroups gmane.text.clearsilver.general
Message-ID <[email protected]>
arko974 wrote:
> i tried to make a loop but it doesn't work and i can't count like that 001, 002, 003 ..... with my loop but rather like that 1,2,3...
> Is someone have any idea ?
Well, obviously, you could do the trick with string.slice(), but it will be
ugly. It would be great if ClearSilver had a full-fledged sprintf, but there
is no notion of varargs.

Anyway, here is how I would do it:

    <?cs loop:i = #0, #100, #1 ?>
        <?cs var:eqpt.revt["ETORS" + string.slice("00", 0, 3 - string.length(i)) + i].value ?>
    <?cs /loop ?>

Sincerely,
Nick