Hi, On Fri, Aug 31, 2018 at 3:26 AM Vivien Kraus <viv...@planete-kraus.eu> wrote: > 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
Clearly, you were not using the version I released two days ago. ;) Sorry about that. gnulib changed the noreturn module to require the manual addition of snippets/_Noreturn. > Did I miss something? Nope. It was me. > 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[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. That looks for all values defined for "i" with indexes in the range of 0 through 5 (six values). Since "i" does not hold any values within that range (or any values at all), nothing gets expanded. > Is there a better way? Take a peek at line 186 in autoopts/tpl/bits.tpl and look for the loop: FOR bit (for-from 0) (for-by 1) =][= "bit" is a sparse structured value. It contains a value for "b-name" for every valid entry. By checking for existence, it is checking to see if there is the current index for "bit" is valid. But you don't care about validity of "i", so: [=FOR i (for-from 0) (for-by 1) (for-to (get "size")) \=] [=foo=][[=(for-index)=]] = [=(for-index)=]; [=ENDFOR=] and never reference "i" because "i" is not defined. NOTE: this will go from 0 thru 5, yielding *six* results. ------------------------------------------------------------------------------ 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