Hello list,

I'm just starting to include autogen in my application.  Everything went
smoothly, except for a few things: _Noreturn.h that I had to copy from
snippets/ to libopts/ after autoreconf, and changing the generated
include guard for the options which happens to match that of (and thus
shadowing) autoopts/options.h (AUTOOPTS_OPTIONS_H_GUARD).  Did I miss
something?

Now my question about for loops.

Suppose I'd like to produce (I don't care about empty lines):

    /* Now set up the first 5 items of bar */
    bar[0] = 0;
    bar[1] = 1;
    bar[2] = 2;
    bar[3] = 3;
    bar[4] = 4;

when my definitions are:

    autogen definitions example;
    example = {
      foo = "bar";
      size = 5;
    };

How should I proceed?  I have tried:

    [+ AutoGen5 template c +]
    [+ for example +]
    /* Now set up the first [+size+] items of [+foo+] */
    [+ for i (for-from 0) (for-to (get "size")) +]
    [+ foo +][[+i+]] = [+i+];
    [+ endfor +]
    [+ endfor +]

but the inner "i" loop is not processed.

The best thing I have come up so far is generate a shell script that
spits out the code:

    [+ AutoGen5 template sh +]
    [+ for example +]
    echo "/* Now set up the first [+size+] items of [+foo+] */"
    for i in $(seq 0 $(expr [+size+] - 1))
    do
        echo "[+foo+][$i] = $i;"
    done
    [+ endfor +]

But I'm not very proud of it.  Is there a better way?

Best regards

Vivien

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Autogen-users mailing list
Autogen-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/autogen-users

Reply via email to