POV-Ray : Newsgroups : povray.general : What use is ifdef ? : Re: What use is ifdef ? Server Time
6 Oct 2024 09:51:35 EDT (-0400)
  Re: What use is ifdef ?  
From: MichaelJF
Date: 3 Mar 2014 14:45:01
Message: <web.5314dabf8b4b40c872f270270@news.povray.org>
"FNH" <nomail@nomail> wrote:
> I know what ifdef does (the example below shows me using it)...
>
> //#declare text2use = 2;
>
> box     {
>         <-10,0,11>,<10,10,10>
>
>         #ifdef(text2use)
>                 texture { pigment { White } }
>         #else
>                 texture { pigment { Green } }
>         #end
>
>         }
>
> .... but I'm struggling to understand when you would use it. Why would you refer
> to a variable you've not defined?  Isn't that just sloppy coding.
>
> Has anyone got/had a real-use case for this command? I'd love to know what I'm
> missing out on.

It is just to ensure that a certain thing exists. Your code will use this thing
and you can define a default value, if you have not defined it earlier - may be
at the command line or with an earlier include or within the code itself.

Best regards,
Michael


Post a reply to this message

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