POV-Ray : Newsgroups : povray.general : #IF question using a substring Server Time
8 Aug 2024 01:22:45 EDT (-0400)
  #IF question using a substring (Message 1 to 6 of 6)  
From: Patrick Dugan
Subject: #IF question using a substring
Date: 9 May 2001 09:55:24
Message: <3af94c4c$1@news.povray.org>
I am trying to determine what the front of a string is and depending on what
that substring is declare certan values.

I am using the following code:

         #if (substr(MyStr,1,1)="0")
            #declare TL = -0.6;
            #declare TR = -0.4;
         #end;

Povray gives me an error on the #if line of:

numeric expression expected but substr found instead.

Is there anyway to get an #if statement to examine a substr for a value?  If
not how do you get around this?


Post a reply to this message

From: Wlodzimierz ABX Skiba
Subject: Re: #IF question using a substring
Date: 9 May 2001 11:26:26
Message: <3af961a2$1@news.povray.org>
Patrick Dugan wrote in message <3af94c4c$1@news.povray.org>...
>I am trying to determine what the front of a string is and depending on what
>that substring is declare certan values.

You should look at description of strcmp() in "Float Functions" chapter. Of
course in POV documentation.

--
#macro Sig(A,B,X)_(A,B)_(B,X)_(X,A)#end#macro _(A,B)cylinder{<A.x,A.y,3>,<B.u,
B.v,3>.1,9}#end global_settings{max_trace_level 9}light_source{0 1}camera{up y
*4right-3*x}blob{_(<3,1>,<1,-5>)_(<2,-2>,<4,-2>)Sig(x,<-1,1.5>,<1,3>)_(z-1,z-4
)pigment{rgb 1}}box{-3 3pigment{rgb 0}finish{reflection 1}hollow} // POV-Ray31


Post a reply to this message

From: Patrick Dugan
Subject: Re: #IF question using a substring
Date: 9 May 2001 14:51:56
Message: <3af991cc$1@news.povray.org>
Thanks!  I only looked in the string function area, I never expected that to
be in the float functions descriptions.

"Wlodzimierz ABX Skiba" <abx### [at] abxartpl> wrote in message
news:3af961a2$1@news.povray.org...
> Patrick Dugan wrote in message <3af94c4c$1@news.povray.org>...
> >I am trying to determine what the front of a string is and depending on
what
> >that substring is declare certan values.
>
> You should look at description of strcmp() in "Float Functions" chapter.
Of
> course in POV documentation.
>
> --
> #macro Sig(A,B,X)_(A,B)_(B,X)_(X,A)#end#macro
_(A,B)cylinder{<A.x,A.y,3>,<B.u,
> B.v,3>.1,9}#end global_settings{max_trace_level 9}light_source{0
1}camera{up y
>
*4right-3*x}blob{_(<3,1>,<1,-5>)_(<2,-2>,<4,-2>)Sig(x,<-1,1.5>,<1,3>)_(z-1,z
-4
> )pigment{rgb 1}}box{-3 3pigment{rgb 0}finish{reflection 1}hollow} //
POV-Ray31
>
>
>


Post a reply to this message

From: Patrick Dugan
Subject: Re: #IF question using a substring
Date: 9 May 2001 15:21:14
Message: <3af998aa$1@news.povray.org>
I tried using the strcmp command but get an error now.  I have tried it via
two methods.
First including the comparison in one line like so:

         #if (strcmp(substr(MyStr,1,1),"1")=0)
              #declare TL = -0.6;
              #declare TR = -0.4;
         #end;


And then by breaking up the commands to separate lines like so:

         #declare SmallStr = substr(MyStr,1,1)
         #declare ZeroFound = strcmp(SmallStr,"0");
         #if (ZeroFound=0)
               #declare TL = -0.6;
               #declare TR = -0.4;
          #end;


In each case Povray informs me that there is no matching } in text.
This code is within a text declaration.

I don't see what is suddenly causing the new error.



"Patrick Dugan" <pat### [at] usnetcomcorpcom> wrote in message
news:3af94c4c$1@news.povray.org...
> I am trying to determine what the front of a string is and depending on
what
> that substring is declare certan values.
>
> I am using the following code:
>
>          #if (substr(MyStr,1,1)="0")
>             #declare TL = -0.6;
>             #declare TR = -0.4;
>          #end;
>
> Povray gives me an error on the #if line of:
>
> numeric expression expected but substr found instead.
>
> Is there anyway to get an #if statement to examine a substr for a value?
If
> not how do you get around this?
>
>
>
>


Post a reply to this message

From: Ron Parker
Subject: Re: #IF question using a substring
Date: 9 May 2001 15:22:55
Message: <slrn9fj68h.jn9.ron.parker@fwi.com>
On Wed, 9 May 2001 14:21:16 -0500, Patrick Dugan wrote:
>          #end;
>
>
>In each case Povray informs me that there is no matching } in text.
>This code is within a text declaration.
>
>I don't see what is suddenly causing the new error.

Perhaps the extra semicolon?

-- 
#macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z a-z)R(a
-z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F T)merge{
P(z+a)P(z-a)R(-z-z-x a)pigment{rgbt 1}hollow interior{media{emission T}}finish{
reflection.1}}#end Z(-x-x.2y)Z(-x-x.4x)camera{location z*-10rotate x*90}


Post a reply to this message

From: Patrick Dugan
Subject: Re: #IF question using a substring
Date: 9 May 2001 20:42:03
Message: <3af9e3db@news.povray.org>
Excellent!  Exactly the problem.  Thank you!

"Ron Parker" <ron### [at] povrayorg> wrote in message
news:slr### [at] fwicom...
> On Wed, 9 May 2001 14:21:16 -0500, Patrick Dugan wrote:
> >          #end;
> >
> >
> >In each case Povray informs me that there is no matching } in text.
> >This code is within a text declaration.
> >
> >I don't see what is suddenly causing the new error.
>
> Perhaps the extra semicolon?
>
> --
> #macro R(L P)sphere{L F}cylinder{L P F}#end#macro P(V)merge{R(z+a z)R(-z
a-z)R(a
> -z-z-z a+z)torus{1F clipped_by{plane{a 0}}}translate V}#end#macro Z(a F
T)merge{
> P(z+a)P(z-a)R(-z-z-x a)pigment{rgbt 1}hollow interior{media{emission
T}}finish{
> reflection.1}}#end Z(-x-x.2y)Z(-x-x.4x)camera{location z*-10rotate x*90}


Post a reply to this message

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