|
|
hi,
I re-wrote the first, buggy version[*] of the macro, with much needed help from
tic & tok -- the in-crowd & Tor Olav. thanks.
so, after some basic testing, here's the second version. as discussed in the
other thread, there are two types of "payload" macros: returning (some) boolean
value, and returning nothing ("void"). the former are useful for computation
type code, the latter for all else. there is as yet no documentation, hope to
finish that in a few days. meanwhile the included demo scene doubles as draft
documentation slash tutorial. anyway..
enjoy, jr.
[*]
<http://news.povray.org/povray.bugreports/thread/%3Cweb.606b7e4b54e5aaba1f9dae3025979125%40news.povray.org%3E/>
Post a reply to this message
Attachments:
Download 'foreach.zip' (5 KB)
|
|
|
|
"jr" <cre### [at] gmailcom> wrote:
> I re-wrote the first, buggy version ...
this second version is slightly changed (keys) and, as a result, more flexible
in choosing the dimension(s). I've done more testing, added proper
documentation, and the demo scene too has been tidied up. in all, version 2 of
'Foreach()' is as it should have been from the beginning.
enjoy, jr.
Post a reply to this message
Attachments:
Download 'foreach2.zip' (9 KB)
|
|
|
|
"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)
|
|