|
![](/i/fill.gif) |
Mike E. wrote:
> I am trying to read a text file and call macros according to the names in
> the file WITHOUT using a look up table with #if #else or #switch etc.
> eg:
>
> assume the text file is: "ROTATE_LEFT","ROTATE_RIGHT",..
>
> #macro ROTATE_LEFT()
> blah blah
> #end
>
> #macro ROTATE_RIGHT()
> blah blah
> #end
>
> #read (MyFile,NAME)
>
> NAME() // call the macro ROTATE_LEFT()
>
> - I know this is illegal but this demonstrates what I would like to do, is
> there some way I can convert the text string directly to a macro
> identifier?
>
>
There is a macro, Parse_String(String) in the strings.inc file that can
sometimes help to get the behavior you want. I am not sure if it is
relevant to your particular need here but in general it offers a way to
have a string that you have composed dynamically somehow, appear to the
parser just as if you had typed it in the source file. My language here
may lack technical exactitude but for instance here is a snippet of
code I am currently using:
#local I=0;#while(I<Grain)
#local SplineDef =
#concat ( "#declare Length_Spline_", str(I,0,0), " = " );
Parse_String(SplineDef)
spline { ....
#local I=I+1;#end
Post a reply to this message
|
![](/i/fill.gif) |