POV-Ray : Newsgroups : povray.general : Strange behavior : Re: Strange behavior Server Time
22 Jun 2024 23:41:59 EDT (-0400)
  Re: Strange behavior  
From: clipka
Date: 16 Jan 2015 22:50:01
Message: <54b9dbe9$1@news.povray.org>
Am 17.01.2015 um 02:05 schrieb eticre:

> this fail
>
> #declare rndx=seed(123);
> #macro rnr(nrx,mii,mxx)
>   #if(mii>=0)
>     (rand(nrx)*(mxx-mii+1)) + mii
>   #else
>     mii+(mxx-mii)*rand(nrx) /////////  LINE 40
>   #end
> #end
>
> #local d=0;
> #local d=rnr(rndx,-20,20);

This is a known issue rooted deep in the current parser (and not due to 
be fixed before implementation of a brand new parser); to work around, 
first assign the expression to a local variable, then finally "return" that:

   #macro rnr(nrx,mii,mxx)
     #if(mii>=0)
       #local result = (rand(nrx)*(mxx-mii+1)) + mii;
     #else
       #local result = mii+(mxx-mii)*rand(nrx);
     #end
     result
   #end

The issue reported by the OP, however, is that this construct allegedly 
doesn't always seem to work either; but for the time being I presume 
that Anthony accidently did something wrong.


Post a reply to this message

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