POV-Ray : Newsgroups : povray.general : #IF question using a substring : Re: #IF question using a substring Server Time
7 Aug 2024 23:21:12 EDT (-0400)
  Re: #IF question using a substring  
From: Patrick Dugan
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

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