Re: problem printing an array in a loop
Brandon Long <[email protected]> Wed, 26 Mar 2008 10:00:46 -0800
| Newsgroups | gmane.text.clearsilver.general |
|---|---|
| Organization | Fiction L Networks |
| Message-ID | <20080326180046.GA16524@bl1> |
There are in-line examples in the documentation, but not much from C,
its mostly from the HDF directly.
Brandon
On 03/26/08 Philippe Le Gal uttered the following other thing:
> Hi Brandon
>
> It works fine with the 'each' syntax.
> I'll try the loop syntax too just to understand it.
> Is there a bank of examples online with program in C and the corresponding cs
> syntaxe ?
>
> Thanks
>
> Philippe
>
> Le Wednesday 26 March 2008 07:59:26 Brandon Long, vous avez écrit :
> > 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
>
--
"Patriotism is the virtue of the vicious"
-- Oscar Wilde
http://www.fiction.net/blong/