POV-Ray : Newsgroups : povray.unofficial.patches : New feature idea : Re: New feature idea Server Time
1 Sep 2024 22:19:08 EDT (-0400)
  Re: New feature idea  
From: Disnel
Date: 6 Oct 2000 05:26:50
Message: <39DD9BB8.BBAD889D@hlavacek-partner.cz>
Dirty trick is to add filter before POV parser, but connected to it
(with access to parser's namespace).

With includes you have good idea. I tried this:

#declare Include="colors.inc"

#include Include

sphere {
   <0, 0, 0>, 1
   texture {
     pigment {color Red}
     finish {ambient 1}
   }
}

and it works. Thus import macro can get string as its parameter.

Disnel

Warp wrote:
> 
>   How hard would it be to implement this feature:
> 
>   If an identifier appears in the script with a certain syntax, eg:
> 
> `identifier` or $identifier$ or #identifier# or whatever,
> 
> then that expression is substituted with the value of the identifier and
> then parsing is continued exactly as if that value had been written
> explicitly in that place.
>   For example (supposing that we use for example the $$ notation) this:
> 
> #declare MyIdentifier = "Another"
> #declare $MyIdentifier$ = 5;
> #declare Something$Another$ = <1,2,3>;
> 
> would be parsed exactly as if we had written:
> 
> #declare MyIdentifier = "Another"
> #declare Another = 5;
> #declare Something5 = <1,2,3>;
> 
>   Why I propose this?
>   There is a discussion in povray.general (IIRC) about how to avoid unnecessary
> parsing of include files that are #included more than once.
>   I thought that perhaps a macro could be done to automatize the ignoring
> of repeated. This macro could be used like:
> 
> import("myinclude.inc")
> 
> which would #include "myinclude.inc" only if it wasn't included before.
> 
>   It's not easy to implement this macro with the current povray script.
> Perhaps simulating some dynamic array and searching that array could be
> done, but that's hard to do and very slow when there are lots of includes.
>   Then I thought about the feature I propose here. The macro could be done
> like:
> 
> #macro import(file)
>   #local ID = strreplace(file, ".", "_");
>   #ifndef(_INCLUDED_$ID_)
>     #declare _INCLUDED_$ID$_
>     #include file
>   #end
> #end
> 
>   (Note also the need for a 'strreplace' function or macro...)
> 
> --
> main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
> ):_;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

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