POV-Ray : Newsgroups : povray.binaries.images : How to concatenate an identifier? : Re: How to concatenate an identifier? Server Time
25 Apr 2024 13:51:13 EDT (-0400)
  Re: How to concatenate an identifier?  
From: William F Pokorny
Date: 28 Sep 2020 08:38:22
Message: <5f71d93e$1@news.povray.org>
On 9/28/20 6:18 AM, jr wrote:
...
> 
> #include "strings.inc"
> 
> #macro Abc(s_)
>    #debug concat(s_, " = ", str(Parse_String(s_),0,2), "\n")
> #end
> 
> #declare name_ = "U";
> 
> Parse_String(concat("#declare ", name_, " = 123.45;"));
> 
> Abc(name_)
> 
...

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.
#macro Parse_String(String)
     #fopen FOut "parse_string.tmp" write
     #write(FOut,String)
     #fclose FOut
     #include "parse_string.tmp"
#end

Bill P.


Post a reply to this message

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