POV-Ray : Newsgroups : povray.general : Convert string identifier to object name : Re: Convert string identifier to object name Server Time
30 Jul 2024 04:25:00 EDT (-0400)
  Re: Convert string identifier to object name  
From: Chris B
Date: 2 Nov 2009 06:26:20
Message: <4aeec1dc@news.povray.org>
"Thomas de Groot" <tDOTdegroot@interDOTnlANOTHERDOTnet> wrote in message 
news:4aeea8ac$1@news.povray.org...
> This is a bit similar to SharkD's question above, but I wonder if it is 
> possible.
>
> What I want to do is the following:
>
> #local PoserName = "Beggar_";
> #include concat(PoserName, "POV_geom.inc")
> #local ObjName = object {PoserName}
>
> The first two line of code work correctly, but the third one generates a 
> parse error of course, as a string identifier instead of an object is 
> found. How can I make this work?
>
> -- 
> All the best,
>
> Thomas
>

I assume that an object called 'Beggar_' is declared within the include 
file?
If so you could use the Parse_String(String) macro. This macro takes a 
string, writes it to a file, and then includes that file, effectively 
evaluating the string, so:

#include "strings.inc"
Parse_String(concat("object {",PoserName,"}"))

should do it. Warning. I didn't test this for syntax errors.

Regards,
Chris B.


Post a reply to this message

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