POV-Ray : Newsgroups : povray.general : New Get macro : New Get macro Server Time: 22 Sep 2020 13:34:56 GMT
  New Get macro  
From: Leroy
Date: 13 Jul 2020 19:50:00
I was going through my old POV files and ran across my Get macro.
Before I tell you about it I need to tell ya why I needed it.

I got tired of have two files for every object file I made. The file itself and
one to display or test what it does.

 So I combine them by using the Get variable. If the Get variable was not
defined then a display would show what the file did. If included from another
file with Get defined, there was no display. Which works for a single call to
a file or a group of files. The trouble comes when you have nest several these
'Get' files.It can be hard to Test just part of the nested group.

What the Get macro does is keep track of how many files have been include and
kills the Get variable when it is no longer needed. Here it is!

#ifndef(Get_Mac_Ver)
 #declare Get_Mac_Ver=1.1;

 #ifdef(Get) #undef Get #end

 #macro StrFill(Str,C,N)//helps display
  #local I=1;
  #while(I<=N) #declare Str=concat(Str,C); #local I=I+1;#end
 #end

 #macro GET(Str)

  #ifndef(Get_Stack_Count) #declare Get_Stack_Count=1;
  #else #declare Get_Stack_Count=Get_Stack_Count+1;
  #end
  #ifdef(View_POV_Include_Stack)
   #local A="";StrFill(A," ",Get_Stack_Count*2)
   #debug concat(A,"Getting  ",Str,"\n")
  #end
  #declare Get=1;
  #include Str
  #declare Get_Stack_Count=Get_Stack_Count-1;
  #if(Get_Stack_Count=0)
   #ifdef(Get) #undef Get #end
  #end
   #ifndef(Get_File_Count) #declare Get_File_Count=1;
   #else #declare Get_File_Count=Get_File_Count+1;
   #end
 #end
#end

This can use #debug.inc to display what files where got.

I was wondering if I should put it on my web site.
Any comment would be helpful
Have Fun!


Post a reply to this message

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