POV-Ray : Newsgroups : povray.newusers : Problem with #switch : Re: Problem with #switch Server Time
28 Jul 2024 18:23:16 EDT (-0400)
  Re: Problem with #switch  
From: Mike the Elder
Date: 11 Feb 2008 19:05:01
Message: <web.47b0e2672c0eb44373e406e60@news.povray.org>
"Archpawn" <nomail@nomail> wrote:
> When I try to compile the following code, it says there should be a ) after X+1.
> Am I doing this right? It's supposed to return X+1 if Dir = 0 or 1, X if it's 2
> or 5, and X-1 if it's 3 or 4.
> #macro NextX(X,Dir)
>    #switch(Dir)
>       #case(0)
>       #case(1)
>          X+1
>       #break
>       #case(2)
>          X
>       #break
>       #case(3)
>       #case(4)
>          X-1
>       #break
>       #case(5)
>          X
>       #break
>    #end
> #end

I think you need to specify where the returned value is to be stored:

#macro NextX(X,Dir)

   #switch(Dir)
      #case(0)
      #case(1)
         #declare RetXVal = X+1;
      #break
      #case(2)
         #declare RetXVal = X;
      #break
      #case(3)
      #case(4)
         #declare RetXVal = X-1;
      #break
      #case(5)
         #declare RetXVal = X;
      #break
   #end
#end


Post a reply to this message

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