Re: problem printing an array in a loop
Brandon Long <[email protected]> Tue, 25 Mar 2008 22:59:26 -0800
| Newsgroups | gmane.text.clearsilver.general |
|---|---|
| Organization | Fiction L Networks |
| Message-ID | <20080326065926.GA22546@bl1> |
On 03/25/08 Eric Brunson uttered the following other thing:
> Philippe Le Gal wrote:
> > Hi,
> >
> > I try to generate an array filled in a c cgi like this :
> >
> > char values[15][4];
> > int x;
> >
> > // populate values
> > for (x = 0; x < 15; x++) {
> > sprintf(values[x], "%d", map[x]);
> > }
> >
> >
> > for (x = 0; x < 15; x++) {
> > hdf_set_valuef(cgi->hdf, "Values.%d=%s", x, values[x]);
> > }
> >
> > I can see that the hdf is filled with the values when debugging :
[snip]
> >
> > But I need a loop to make the job. So I tried :
> >
> > <?cs loop:x=#0,#15 ?><?cs var:Values.x ?><?cs /loop ?>
The right syntax here is:
<?cs loop:x=#0,#15 ?><?cs var:Values[x] ?><?cs /loop ?>
or even:
<?cs loop:x=15 ?><?cs var:Values[x] ?><?cs /loop ?>
though that's pretty gross (assumes start is 0). I'm really not a fan
of the loop syntax...
> Have you tried:
>
> <?cs for: v in Values ?><?cs var: v ?><?cs /loop ?>
The right one here is:
<?cs each:v=Values ?><?cs var:v ?><?cs /loop ?>
Brandon
--
"There are Gods older than the ones you know, their true names long
forgotten. They are still here. We do not even think of them as
Gods, but we worship them today."
-- PLIF 2001-07-12 http://www.plif.com/archive/wc274.gif