POV-Ray : Newsgroups : povray.binaries.images : How to concatenate an identifier? : Re: How to concatenate an identifier? Server Time
18 Apr 2024 19:27:34 EDT (-0400)
  Re: How to concatenate an identifier?  
From: jr
Date: 28 Sep 2020 09:30:09
Message: <web.5f71e4efc09da16c4d00143e0@news.povray.org>
hi,

William F Pokorny <ano### [at] anonymousorg> wrote:
> On 9/28/20 6:18 AM, jr wrote:
> > ...
> > Parse_String(concat("#declare ", name_, " = 123.45;"));
> > ...
>
> Expect most know, but on seeing this thread I added the follow comments
> to povr's string.inc file:
>
> // Parse a string you create (i.e., = concat(...)) - while parsing.
> // Use carefully. This macro a hack using a file which can collide
> // by name across invocations of povray or during multiple
> // simultaneous povray commands. Further, in opening and closing a
> // file it is also inefficient if done many times. Often it's
> // better to use the same "include defined strings for parsing"
> // idea by writing many 'to be parsed strings' to a file and then
> // include that single file by a name which you know and control.
> ...

wondering whether the recommendation should not follow Kenneth's preference (ie
cut/paste macro in to scene) since it is "self-modifying" code.  also thinking,
wrt file name collision(s), perhaps a new version 2 of the macro could (should?)
be added to the POV-Ray/povr distributions, putting the user "in charge".  eg:

#macro Parse_String_2(Fname, String)
  #fopen FP Fname write
  #write(FP, String)
  #fclose FP
  #include Fname
#end


regards, jr.


Post a reply to this message

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