POV-Ray : Newsgroups : povray.pov4.discussion.general : Feature request: Strings in "switch" statements Server Time
22 Dec 2024 12:44:07 EST (-0500)
  Feature request: Strings in "switch" statements (Message 1 to 2 of 2)  
From: SharkD
Subject: Feature request: Strings in "switch" statements
Date: 25 Jun 2008 17:05:01
Message: <web.4862b25f88b3e5e9388aeae80@news.povray.org>
I would like to request that strings be allowed in switch statements. This is a
pretty common feature in programming languages, and I was kind of disappointed
that POV-Ray doesn't allow this. I like to use strings as configuration
settings, as they're more readable, and then use a switch statement to check
their values.

Thanks.

-Mike


Post a reply to this message

From: Zeger Knaepen
Subject: Re: Feature request: Strings in "switch" statements
Date: 26 Jun 2008 16:41:06
Message: <4863fee2$1@news.povray.org>
"SharkD" <nomail@nomail> wrote in message 
news:web.4862b25f88b3e5e9388aeae80@news.povray.org...
>I would like to request that strings be allowed in switch statements. This 
>is a
> pretty common feature in programming languages, and I was kind of 
> disappointed
> that POV-Ray doesn't allow this. I like to use strings as configuration
> settings, as they're more readable, and then use a switch statement to 
> check
> their values.

actually sounds like you would be better off defining some constants and 
using those:

---- start code UsefullMacros.inc ----
#declare SPHERE=1;
#declare CYLINDER=2;
#declare BOX=3;

#macro Shape(Type)
    #switch(Type)
        #case (SPHERE)
            sphere {0,1}
            #break
        #case (CYLINDER)
            cylinder {-y,y,1}
            #break
        #case (BOX)
            box {-1,1}
            #break
    #end
#end

---- end code UsefullMacros.inc ----
---- start code UsefullMacrosTest.pov ----
#include "UsefullMacros.inc"
Shape(SPHERE)
---- end code UsefullMacrosTest.pov ----

cu!
-- 
#macro G(b,e)b+(e-b)*C/50#end#macro _(b,e,k,l)#local C=0;#while(C<50)
sphere{G(b,e)+3*z.1pigment{rgb G(k,l)}finish{ambient 1}}#local C=C+1;
#end#end _(y-x,y,x,x+y)_(y,-x-y,x+y,y)_(-x-y,-y,y,y+z)_(-y,y,y+z,x+y)
_(0x+y.5+y/2x)_(0x-y.5+y/2x)            // ZK http://www.povplace.com


Post a reply to this message

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