POV-Ray : Newsgroups : povray.general : #ifdef using a string expression? : Re: #ifdef using a string expression? Server Time
9 May 2024 08:52:59 EDT (-0400)
  Re: #ifdef using a string expression?  
From: Kenneth
Date: 11 Apr 2023 08:25:00
Message: <web.64354efe98df09c99b4924336e066e29@news.povray.org>
"Kenneth" <kdw### [at] gmailcom> wrote:
> (v3.8.0 beta 1 in Windows 10)
>
> I was playing around with #ifdef recently; just experimenting.
>
Here's another example of an #ifdef feature that would be useful, IMO. I
recently had a need for it:
     #ifdef(AA & BB)

Apparently, it doe not (yet) work with 'tuples' like the newer v3.8 #declare
does, for example. Nor with boolean operators, so it seems.

I tried several workarounds for this, in various syntax forms. My first attempt
was with nested #ifdef's, possibly using an #elseif somewhere-- but I am not
very familiar with the #elseif construct and could not come up with a code
block that seemed 'reliable' or logically consistent:

#declare AA=3;
#declare BB=7;

#ifdef(AA)
     #ifdef(BB)
     ... do this...
    (or  #elseif   ...do this... ?)
#else (?)
... do that...
#end

My 2nd attempt was with an enclosing #if, again in various syntax forms-- but
this causes fatal errors, and I'm not sure that I understand why:

#if(#ifdef(AA) & #ifdef(BB)) // this line does not work, even though an #if can
                             // itself use boolean operators
...do this...
#else
...do that...
#end

For the first line, a simpler  #if(#ifdef(AA)) does not work either, nor does
#if(#ifdef(AA)=true))

Any suggestions or comments? It seems to me that at least one of these schemes
*should* work, unless I'm making a basic error or wrong assumption somewhere.

The current v3.8 operation of #ifdef is...ill-defined... so maybe that's part of
the problem(?)


Post a reply to this message

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