|
|
"jr" <cre### [at] gmailcom> wrote:
> "jr" <cre### [at] gmailcom> wrote:
> > I re-wrote the first, buggy version ...
> this second version ...
and now a snapshot of #3. some new features, improved documentation. I will
have to put in some more work to provide a good set of tutorial examples, a new
demo scene, etc, but would meanwhile ask interested parties to give 'Foreach' a
try, see which bugs still lurk :-).
not documented because I've only done two tests so far is nesting of 'Foreach'
calls; I have managed to call the macro from a payload macro (with different
array + payload, of course).
an example of calling 'Foreach' with the new 'Indices' and 'Arg' features:
#version 3.8;
global_settings {assumed_gamma 1}
#include "foreach.inc"
#declare A = array [2][2][3] {
{{1, 2, 3}, {4, 5, 6}},
{{7, 8, 9}, {10, 11, 12}}
};
#macro m_walka(i_, j_, k_, elem_, arg_)
#local n_ = elem_ * elem_;
#debug concat("m_walka i = ",str(i_,0,0),", elem = ",str(elem_,0,0),
" arg = '",arg_.foo,"' and ",str(arg_.bar,0,0),".\n")
#end
#declare foober = dictionary {
.foo: "this is nice.",
.bar: 12345
};
#declare D = dictionary {
.Macro: "m_walka",
.Arg: "foober",
.Walk: 1,
.To: 3,
.Extra: on,
.Indices: on,
.Verbose: on
};
Foreach(A, D)
enjoy, jr.
Post a reply to this message
Attachments:
Download 'foreach3.zip' (8 KB)
|
|