POV-Ray : Newsgroups : povray.bugreports : local in macro : Re: local in macro Server Time
20 Apr 2024 00:28:16 EDT (-0400)
  Re: local in macro  
From: Bald Eagle
Date: 28 Nov 2019 10:25:01
Message: <web.5ddfe6578fffca174eec112d0@news.povray.org>
> #version 3.8;
>
> global_settings {assumed_gamma 1}
>
> #macro Decr(n_)
>   #if (1 <= n_)
>     #local n_ = n_ - 1;
>   #end
>   #debug concat("local n_ = ",str(n_,0,0),"\n")
> #end
>
>
> #if (1)
> #for (i_,0,3)
>   Decr(i_)
>   #debug concat("loop i_ = ",str(i_,0,0),"\n")
> #end
> #end
>
>
> #if (0)
> #declare i_ = 0;
> #while (4 > i_)
>   Decr(i_)
>   #debug concat("loop i_ = ",str(i_,0,0),"\n")
>   #declare i_ = i_ + 1;
> #end
> #end

Not sure exactly what you're trying to do here, but try this and see if this
helps explain anything.   I think Kenneth had some issues with this sort of
thing too a while back.

#version 3.8;

global_settings {assumed_gamma 1}

#declare Bailout = 0;
#declare Bailoutmax = 10;

#macro Decr (n_)
 #debug concat("starting macro with n_ = ",str(n_,0,0),"\n")
 #if (n_ >= 1)
  #local n_ = n_ - 1;
 #end


 #if (Bailout = Bailoutmax)
  #error "Stopping code - Bailout has reached max"
 #end

 #debug concat("     exiting macro with n_ = ",str(n_,0,0),"\n")
 n_

#end


#if (1)
 #declare Counter = 10;
 #for (i_, 0, 3)
  #declare Counter = Decr (Counter);
  #declare Bailout = Bailout + 1;

 #end
#end


#if (0)
 #declare i_ = 0;
 #while (i_ < 4)
  #declare i_ = Decr (i_);
  #debug concat("while loop i_ = ",str(i_,0,0),"\n")
  #declare Bailout = Bailout + 1;
  #declare i_ = i_ + 1;
 #end
#end

#error "stop render"


Post a reply to this message

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