Re: problem printing an array in a loop

Eric Brunson <[email protected]> Wed, 26 Mar 2008 12:15:39 -0600
Newsgroups gmane.text.clearsilver.general
Message-ID <[email protected]>
Brandon Long wrote:

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 ?>

Ooops, I was going from memory and didn't look at the docs. Sorry.

__._,_.___

Messages in this topic (7)

Reply (via web post) |
Start a new topic

Messages

| Members

http://groups.yahoo.com/;_ylc=X3oDMTJkMGZvbTIzBF9TAzk3NDc2NTkwBGdycElkAzM1NjQxMzcEZ3Jwc3BJZAMxNzA3MjgxOTQyBHNlYwNmdHIEc2xrA2dmcARzdGltZQMxMjA2NTU1NDE2

Change settings via the Web (Yahoo! ID required)

Change settings via email: Switch delivery to Daily Digest | Switch format to Traditional

Visit Your Group |
Yahoo! Groups Terms of Use |
Unsubscribe

Recent Activity

-

2

New Members

Visit Your Group

Yahoo! Finance

It's Now Personal

Guides, news,

advice & more.

Search Ads

Get new customers.

List your web site

in Yahoo! Search.

Best of Y! Groups

Check out the best

of what Yahoo!

Groups has to offer.

.

__,_._,___