POV-Ray : Newsgroups : povray.text.scene-files : foreach macro Server Time
15 Jun 2021 05:28:46 EDT (-0400)
  foreach macro (Message 1 to 10 of 30)  
Goto Latest 10 Messages Next 10 Messages >>>
From: jr
Subject: foreach macro
Date: 5 Apr 2021 18:30:00
Message: <web.606b8ee6a800902b79819d986cde94f1@news.povray.org>
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)

From: jr
Subject: Re: foreach macro
Date: 9 Apr 2021 09:35:00
Message: <web.60705575d564bfd479819d986cde94f1@news.povray.org>
"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)

From: ingo
Subject: Re: foreach macro
Date: 9 Apr 2021 13:26:53
Message: <XnsAD07C5D59D4Aseed7@news.povray.org>
in news:web.60705575d564bfd479819d986cde94f1@news.povray.org jr wrote:

> 'Foreach()'

This is useful. Thanks,

Ingo


Post a reply to this message

From: jr
Subject: Re: foreach macro
Date: 10 Apr 2021 03:35:00
Message: <web.607154f7d564bfd479819d986cde94f1@news.povray.org>
hi,

ingo <ing### [at] tagpovrayorg> wrote:
> > 'Foreach()'
>
> This is useful. Thanks,

cheers.  (I see you're "knee-deep" in arrays right now :-))

btw, 'pluck a string' sounds pretty real.  amazing.


regards, jr.


Post a reply to this message

From: ingo
Subject: Re: foreach macro
Date: 10 Apr 2021 07:26:10
Message: <XnsAD0888A8C53D1seed7@news.povray.org>
in news:web.607154f7d564bfd479819d986cde94f1@news.povray.org jr wrote:

> I see you're "knee-deep" in arrays right now

Arrays (and dicts) are indispensable imo.

Ingo


Post a reply to this message

From: jr
Subject: Re: foreach macro
Date: 14 Apr 2021 16:50:00
Message: <web.6077545ad564bfd479819d986cde94f1@news.povray.org>
"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)

From: jr
Subject: Re: foreach macro
Date: 16 Apr 2021 13:05:00
Message: <web.6079c30bd564bfd479819d986cde94f1@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> ...
> and now a snapshot of #3.  ...

another snapshot of #3.  minor progress in .inc and .html files.  the
'fore_demo.pov' scene has been re-written.  now call:

  $ povray fore_demo.pov declare=N=i

where 1 <= i <= 5.  all but 5 (default when declare omitted) only output text
info during parsing.


enjoy, jr.


Post a reply to this message


Attachments:
Download 'foreach3a.zip' (11 KB)

From: jr
Subject: Re: foreach macro
Date: 16 Apr 2021 16:45:00
Message: <web.6079f615d564bfd479819d986cde94f1@news.povray.org>
"jr" <cre### [at] gmailcom> wrote:
> ...
> the 'fore_demo.pov' scene has been re-written.  ...

looking at the scene code just now I noticed a couple of (potentially) confusing
copy+paste errors.  </sigh>  the 'm_2arg' and 'm_dict' macros display wrong
names, sorry.


regards, jr.


Post a reply to this message

From: ingo
Subject: Re: foreach macro
Date: 16 Apr 2021 17:05:51
Message: <XnsAD0EEAF4F3831seed7@news.povray.org>
in news:web.6079f615d564bfd479819d986cde94f1@news.povray.org jr wrote:

></sigh>

Ah, the sound of enthousiasm :)

Ingo


Post a reply to this message

From: jr
Subject: Re: foreach macro
Date: 16 Apr 2021 17:50:00
Message: <web.607a05bad564bfd479819d986cde94f1@news.povray.org>
hi,

ingo <ing### [at] tagpovrayorg> wrote:
> in news:web.6079f615d564bfd479819d986cde94f1@news.povray.org jr wrote:
>
> ></sigh>
>
> Ah, the sound of enthousiasm :)

</grin>  thanks.

btw, as Robert writes, the mp3 plays fine.  checked with 'mpg123' on another
machine.


regards, jr.


Post a reply to this message

Goto Latest 10 Messages Next 10 Messages >>>

Copyright 2003-2021 Persistence of Vision Raytracer Pty. Ltd.