POV-Ray : Newsgroups : povray.general : New Get macro Server Time: 6 Aug 2020 11:02:52 GMT
  New Get macro (Message 1 to 5 of 5)  
From: Leroy
Subject: New Get macro
Date: 13 Jul 2020 19:50:00
Message: <web.5f0cba1a35748460e3ef795d0@news.povray.org>
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

From: Bald Eagle
Subject: Re: New Get macro
Date: 13 Jul 2020 21:35:03
Message: <web.5f0cd26e4810ab9ffb0b41570@news.povray.org>
"Leroy" <whe### [at] gmailcom> wrote:

>  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!

So - this seems very much like how I set up a lot of my include files - using an
"SDL" variable - which if set, ignores the leading code block of the file, and
if not, #declares all of the usual things one needs to render the file (as a
standalone scene) like #version, camera, light_source, etc.

You've gone an extra step and created a macro and stack - which is what I've
been playing with in another set of files that is under development.

I think what you have is good - and would benefit from being supplemented with a
series of files to demonstrate the function and utility of the macro, and
highlight the tricky situation(s) that might exist and which the macro and stack
solves.
Then wrap it up in a [version-marked] zip file.


Post a reply to this message

From: Leroy
Subject: Re: New Get macro
Date: 22 Jul 2020 17:35:01
Message: <web.5f1877ef4810ab9ff5aca43f0@news.povray.org>
"Bald Eagle" <cre### [at] netscapenet> wrote:

> So - this seems very much like how I set up a lot of my include files - using an
> "SDL" variable - which if set, ignores the leading code block of the file, and
> if not, #declares all of the usual things one needs to render the file (as a
> standalone scene) like #version, camera, light_source, etc.
>
> You've gone an extra step and created a macro and stack - which is what I've
> been playing with in another set of files that is under development.
>
> I think what you have is good - and would benefit from being supplemented with a
> series of files to demonstrate the function and utility of the macro, and
> highlight the tricky situation(s) that might exist and which the macro and stack
> solves.
> Then wrap it up in a [version-marked] zip file.

 Thanks for your advice. I have a bunch files I used to test the macro. I just
need to clean them up and create an read me file. I showed the macro here as
kind of a teaser, just to show its basic set up. So people could evaluate it.

 It's hard for me to decided just what I should put on my website that other
people can use. There are things there that should be dropped or reworked.

 I don't get on the net to often (as you can tell by this late reply) and when I
do there is so much stuff to do that I don't chat as much as I should. So I
don't get a good feel of what is useful to other users of POV-ray.

Have Fun!


Post a reply to this message

From: ingo
Subject: Re: New Get macro
Date: 3 Aug 2020 06:01:15
Message: <XnsAC0E5196CA622seed7@news.povray.org>
in news:web.5f0cba1a35748460e3ef795d0@news.povray.org Leroy wrote:

>  So I combine them by using the Get variable. If the Get variable was
>  not 

This is what I add to the bottom of my include files

#if(input_file_name="yourfile.inc")

   put the test scene here

#end

When the .inc file is included from somewhere it does not render the test 
scene. If run solo it renders the test.

Ingo


Post a reply to this message

From: William F Pokorny
Subject: Re: New Get macro
Date: 3 Aug 2020 13:04:40
Message: <5f280b68@news.povray.org>
On 8/3/20 2:01 AM, ingo wrote:
> in news:web.5f0cba1a35748460e3ef795d0@news.povray.org Leroy wrote:
> 
>>   So I combine them by using the Get variable. If the Get variable was
>>   not
> 
> This is what I add to the bottom of my include files
> 
> #if(input_file_name="yourfile.inc")
> 
>     put the test scene here
> 
> #end
> 
> When the .inc file is included from somewhere it does not render the test
> scene. If run solo it renders the test.
> 
> Ingo
> 

Thank you! A neat trick. Happens I was recently thinking about the lack 
of general testing of the shipped include files. I have Worries a few 
macros might not be working properly glancing at the code.

Bill P.


Post a reply to this message

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