POV-Ray : Newsgroups : povray.newusers : if inside a macro syntax (if...else) : Re: if inside a macro syntax (if...else) Server Time
30 Jul 2024 00:25:52 EDT (-0400)
  Re: if inside a macro syntax (if...else)  
From: Neil Kolban
Date: 30 Dec 2004 00:44:43
Message: <41d395cb$1@news.povray.org>
Rafal,
Hi my friend.

The expression "?" component works fine but I think you have two errors:

1. You can't have a variable called "size".  That is a keyword.
2. The syntax for the conditional expression is:

( C ? A : B )

and not

C ? A : B

You had missed the brackets

In my tests,

#local big=false;
#local msize = (big ? 100 : 50);
#debug concat("Output: ",str(msize,1,1),"\n")

and

#local big=true;
#local msize = (big ? 100 : 50);
#debug concat("Output: ",str(msize,1,1),"\n")

work as expected.

See 3.2.1.3.3 Operators in the POV-Ray docs.

Neil


"Rafal 'Raf256' Maj" <spa### [at] raf256com> wrote in message
news:Xns95CF3BB3DD30Araf256com@203.29.75.35...
>
> Hi,
> syntax like
>
> #local size = big ? 100 : 50;
>
> (from C "operator?" ) isnt working, and writting it normaly as:
>
> #if (big) #local size=100; #else #local size=50; #end
>
> is quite long (I like to keep my syntax short). So I wanted to write a
tiny
> IfElse function, like:
>
> #macro IfElse(A,B,C) #if (A) 55 #else 30 #end #end
>
> #local DD = IfElse(variant_Wide, 50, 100);
>
> but it gaves a pares error.
>
> I replaced it with good sytnax:
>   #macro IfElse(A,B,C) select(A-1,C,B,C) #end
> that do work, but just for curiosity, how to make previous syntax work
> also?
>
> -- 
> http://www.raf256.com/3d/
> Rafal Maj 'Raf256', home page - http://www.raf256.com/me/
> Computer Graphics


Post a reply to this message

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