POV-Ray : Newsgroups : povray.newusers : conditional statements : Re: conditional statements Server Time
6 Oct 2024 02:17:17 EDT (-0400)
  Re: conditional statements  
From: clipka
Date: 17 Jul 2009 05:50:01
Message: <web.4a6048b86dc58f70a4aed1130@news.povray.org>
"mysdn" <kam### [at] hotmailcom> wrote:
> is it possible to write
>
>  #if (DoorModel == model_101)   in an if statement

In POV 3.6, you can achieve this using:

  #if (strcmp(DoorModel,model_101)) ...

In POV 3.7, POV-Ray's comparison operator works for strings, too, so you can
also use:

  #if (DoorModel = model_101) ...

(Note the single equals sign; POV-Ray does *not* use C/C++ style operators.)


> and  in switches
>
>   #switch(DoorModel)
>
>            #case (model_101)// do that
>
> I want to test for strings, is ttah possible in pov.

No, that's only possible with float values, even in 3.7.

Out of curiosity: Are you sure you want to use strings for the model
identifiers? A numeric id would do, I guess. After all, you can always use
those identifiers you have, like model_101, so you don't have to memorize all
the - possibly cryptic - ids.

If you absolutely need to work with strings for model identifiers, I suggest
translating them to numerical ids first, by looking them up in an array.


Post a reply to this message

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