POV-Ray : Newsgroups : povray.beta-test : No String Parameters for Macros? Server Time
29 Jul 2024 00:35:23 EDT (-0400)
  No String Parameters for Macros? (Message 1 to 7 of 7)  
From: Sven Littkowski
Subject: No String Parameters for Macros?
Date: 16 Nov 2006 07:01:39
Message: <455c5323$1@news.povray.org>
I had a problem with my macro: it seems, macros don't accept string 
parameters, only numerical values. Is that true?

I am using the latest beta version. (By mistake, I posted this thread in 
another section, sorry.)

Greetings,

Sven


Post a reply to this message

From: Nicolas Calimet
Subject: Re: No String Parameters for Macros?
Date: 16 Nov 2006 07:24:54
Message: <455c5896$1@news.povray.org>
> I had a problem with my macro: it seems, macros don't accept string 
> parameters, only numerical values. Is that true?

	Please provide a minimal test scene.

> (By mistake, I posted this thread in 
> another section, sorry.)

	Why not canceling a message you just posted?  Doesn't MS OE support
that feature?

	- NC


Post a reply to this message

From: Sven Littkowski
Subject: Re: No String Parameters for Macros?
Date: 16 Nov 2006 07:37:23
Message: <455c5b83$1@news.povray.org>
True, I should have added the sample code. Here is the macro:

#macro Exit(Sign,SignWhere,Angle,Rotation,Translation)
 union
 {
  difference
  {
   union
   {
    cylinder // Round Wall
    {
     < -0.025, 0.0, 0.0 > < 0.025, 0.0, 0.0 > 1.20
     pigment
     {
      gradient y
      pigment_map
      {
       [ 0.0 rgb < 0.3137255, 0.3882353, 0.5607843 > ]
       [ 0.3 rgb < 0.3137255, 0.3882353, 0.5607843 > ]
       [ 0.3 White ]
       [ 1.0 White ]
      }
      scale 2.40
      translate < 0.0, -1.20, 0.0 >
     }
    }
    box // Door Frame
    {
     < -0.035, -1.05, -0.55 > < 0.035, 1.05, 0.55 >
     pigment { Black }
    }
   }
   box // Door Cut-Out
   {
    < -0.036, -1.0, -0.5 > < 0.036, 1.0, 0.5 >
    pigment { Black }
   }
  }
  union
  {
   difference
   {
    box // Door
    {
     < -0.055, -1.0, -0.5 > < 0.055, 1.0, 0.5 >
     pigment { White }
    }
    cylinder // Window Cut-Out
    {
     < -0.056, 0.4, 0.0 > < 0.056, 0.4, 0.0 > 0.10
     pigment { Black }
    }
   }
   torus
   {
    0.10, 0.025
    pigment { rgb < 0.9960784,  0.7686275,  0.2392157 > }
    translate < 0.0, 0.0, 0.30 >
   }
   #if(Sign!="") 
////////////////////////////////////////////////////////////////////////////// 
HERE IS THE ERROR
    #if(SignWhere="A")
     box { < -0.000, 0.6, -0.20 > < 0.056, 0.8, 0.20 > pigment { Black } 
rotate < 0.0, 000.0, 0.0 > }
    #end
    #if(SignWhere="B")
     box { < -0.000, 0.6, -0.20 > < 0.056, 0.8, 0.20 > pigment { Black } 
rotate < 0.0, 180.0, 0.0 > }
    #end
   #end
   #if(Angle>90.0)
    #declare Angle=90.0;
   #end
   #if(Angle<-90.0)
    #declare Angle=-90.0;
   #end
   translate < 0.0, 0.0, 0.5 >
   rotate < 0.0, Angle, 0.0 >
   translate < 0.0, 0.0, -0.5 >
  }
  rotate Rotation
  translate Translation
 }
#end

And here is the call to that macro:

 Exit("A",0,+70,< 0.0, 090.0, 0.0 >,< -0.0, 1.5, 3.85 >)  // Exits

This causes the error message "Numerical value expected but string value 
found" (something like that).

Sven


Post a reply to this message

From: Trevor G Quayle
Subject: Re: No String Parameters for Macros?
Date: 16 Nov 2006 08:45:00
Message: <web.455c6ad6102a121ac150d4c10@news.povray.org>
"Sven Littkowski" <sve### [at] jamaica-focuscom> wrote:
>    #if(Sign!="")

The problem is not the macro.  It's that #if expects numericals and does not
accept strings.  Try using the strcmp() function which compares strings:

   #if (strcmp(Sign,"")!=0)  //TRUE if (Sign != ""), strcmp()returns 0 if
both strings are equal


>     #if(SignWhere="A")
>     #if(SignWhere="B")

You're also going to have to fix this.  You pass a number for SignWhere, but
try to use it as a string.  Choose which you want and modify accordingly.

>  Exit("A",0,+70,< 0.0, 090.0, 0.0 >,< -0.0, 1.5, 3.85 >)  // Exits


-tgq


Post a reply to this message

From: Sven Littkowski
Subject: Re: No String Parameters for Macros?
Date: 16 Nov 2006 13:22:12
Message: <455cac54@news.povray.org>
Trevor,

thanks a lot! Your hint works for me.

Greetings,

Sven


Post a reply to this message

From: Warp
Subject: Re: No String Parameters for Macros?
Date: 16 Nov 2006 17:01:49
Message: <455cdfcd@news.povray.org>
Trevor G Quayle <Tin### [at] hotmailcom> wrote:
> The problem is not the macro.  It's that #if expects numericals and does not
> accept strings.

  A shortcoming which, IMO, should be fixed. I see absolutely no reason
for strings not supporting the comparison operators.

-- 
                                                          - Warp


Post a reply to this message

From: Nicolas Alvarez
Subject: Re: No String Parameters for Macros?
Date: 30 Nov 2008 19:58:13
Message: <493336a5@news.povray.org>
Warp wrote:
> Trevor G Quayle <Tin### [at] hotmailcom> wrote:
>> The problem is not the macro.  It's that #if expects numericals and does
>> not accept strings.
> 
>   A shortcoming which, IMO, should be fixed. I see absolutely no reason
> for strings not supporting the comparison operators.

For the benefit of people reading old threads: this was added in
3.7.beta.23.

 "Added comparison ('=', '!=', '<', '<=', '>', '>=') support for strings."


Post a reply to this message

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