Search the web
Sign In
New User? Sign Up
ClearSilver
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
problem printing an array in a loop   Message List  
Reply | Forward Message #1169 of 1347 |
Re: problem printing an array in a loop

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.




Wed Mar 26, 2008 6:15 pm

ericbrunson
Offline Offline
Send Email Send Email

Forward
Message #1169 of 1347 |
Expand Messages Author Sort by Date

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",...
Philippe Le Gal
philippe.legal@...
Send Email
Mar 25, 2008
11:39 pm

... Have you tried: <?cs for: v in Values ?><?cs var: v ?><?cs /loop ?>...
Eric Brunson
ericbrunson
Offline Send Email
Mar 25, 2008
11:42 pm

... [snip] ... 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 ?> ...
Brandon Long
blong42
Offline Send Email
Mar 26, 2008
6:59 am

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...
Philippe Le Gal
philippe.legal@...
Send Email
Mar 26, 2008
7:55 am

There are in-line examples in the documentation, but not much from C, its mostly from the HDF directly. Brandon ... -- "Patriotism is the virtue of the...
Brandon Long
blong42
Offline Send Email
Mar 26, 2008
6:03 pm

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...
Eric Brunson
ericbrunson
Offline Send Email
Mar 26, 2008
6:16 pm

... It's works...so simple... Thanks Philippe...
Philippe Le Gal
philippe.legal@...
Send Email
Mar 26, 2008
7:01 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help