POV-Ray : Newsgroups : povray.general : using a charact as #macro paramater? Server Time
20 Nov 2024 12:29:35 EST (-0500)
  using a charact as #macro paramater? (Message 1 to 6 of 6)  
From: Steve
Subject: using a charact as #macro paramater?
Date: 27 Aug 2001 11:19:42
Message: <slrn9okp6q.t5t.steve@zero-pps.localdomain>
Hi All

I've written a small macro to place chess pieces, I'm trying to call 
the macro like this:

object{ place_piece(Black_Pawn, H, 2, 0) }

I've also tried 

object{ place_piece(Black_Pawn, "H", 2, 0) }

But keep getting error messages, I've changed the 
values in the switch evaluation to include the quote 
marks etc but nothing seems to be working. 

The macro doesn't seem to be able to take a character as a 
paramater.  

I'm getting errors like:

Parsing................................union{
      object{place_piece(Black_Pawn, "H", 2, 0)
object{Chess_Piece

       #switch (XFile <----ERROR

/home/sjlen/pov/blchess.pov:249: error: numeric expression expected but string
identifier found instead.

Any help gratefully receive. 

--
Cheers
Steve              email mailto:ste### [at] zeroppsuklinuxnet

%HAV-A-NICEDAY Error not enough coffee  0 pps. 

web http://www.zeropps.uklinux.net/

or  http://start.at/zero-pps

  4:13pm  up 44 days, 18:17,  2 users,  load average: 1.14, 1.13, 1.04


Post a reply to this message

From: Ron Parker
Subject: Re: using a charact as #macro paramater?
Date: 27 Aug 2001 11:31:15
Message: <slrn9okpu5.m0.ron.parker@fwi.com>
On 27 Aug 2001 11:19:42 -0400, Steve wrote:
>
>       #switch (XFile <----ERROR
>
>/home/sjlen/pov/blchess.pov:249: error: numeric expression expected but string
>identifier found instead.

The problem isn't the macro, it's the switch.  Switches don't work with
strings.  You can either use a chain of #if...#else #if...#else statements,
or you can switch to using numbers instead of letters.

-- 
plane{-z,-3normal{crackle scale.2#local a=5;#while(a)warp{repeat x flip x}rotate
z*60#local a=a-1;#end translate-9*x}pigment{rgb 1}}light_source{-9red 1rotate 60
*z}light_source{-9rgb y rotate-z*60}light_source{9-z*18rgb z}text{ttf"arial.ttf"
"RP".01,0translate-<.6,.4,.02>pigment{bozo}}light_source{-z*3rgb-.2}//Ron Parker


Post a reply to this message

From: Steve
Subject: Re: using a charact as #macro paramater?
Date: 27 Aug 2001 12:35:46
Message: <slrn9okqqs.ti2.steve@zero-pps.localdomain>
On 27 Aug 2001 11:31:15 -0400, Ron Parker wrote:
>On 27 Aug 2001 11:19:42 -0400, Steve wrote:
>>
>>       #switch (XFile <----ERROR
>>
>>/home/sjlen/pov/blchess.pov:249: error: numeric expression expected but string
>>identifier found instead.
>
>The problem isn't the macro, it's the switch.  Switches don't work with
>strings.  You can either use a chain of #if...#else #if...#else statements,
>or you can switch to using numbers instead of letters.

Thanks Ron I'll change it to if's 

--
Cheers
Steve              email mailto:ste### [at] zeroppsuklinuxnet

%HAV-A-NICEDAY Error not enough coffee  0 pps. 

web http://www.zeropps.uklinux.net/

or  http://start.at/zero-pps

  4:45pm  up 44 days, 18:50,  2 users,  load average: 1.00, 1.01, 1.00


Post a reply to this message

From: Chris Huff
Subject: Re: using a charact as #macro paramater?
Date: 27 Aug 2001 16:32:24
Message: <chrishuff-599533.15283527082001@netplex.aussie.org>
In article <slr### [at] fwicom>,
 ron### [at] povrayorg (Ron Parker) wrote:

> The problem isn't the macro, it's the switch.  Switches don't work with
> strings.  You can either use a chain of #if...#else #if...#else statements,
> or you can switch to using numbers instead of letters.

You might do the latter using the asc() function:

#switch(asc(Choice))
    #case(asc("A"))
    ...

-- 
Christopher James Huff - chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

From: Bob H 
Subject: Re: using a charact as #macro paramater?
Date: 27 Aug 2001 16:42:22
Message: <3b8ab0ae@news.povray.org>
Actually, you might be able to use  asc("H")  to get the number of a letter
(character code) and then use that as the switch parameter.  Could even use
small and capital letters, or other symbols, just open a character map to
see what's what.  "A" starts at 65 and integer count goes up from there to Z
then there's a few symbols between before "a" at number 97.  Caution:
there's several reserved small letters as you probably know.

Bob H.


Post a reply to this message

From: Steve
Subject: Re: using a charact as #macro paramater?
Date: 27 Aug 2001 17:13:50
Message: <slrn9oldkl.uau.steve@zero-pps.localdomain>
On Mon, 27 Aug 2001 15:28:35 -0500, Chris Huff wrote:
>In article <slr### [at] fwicom>,
> ron### [at] povrayorg (Ron Parker) wrote:
>
>> The problem isn't the macro, it's the switch.  Switches don't work with
>> strings.  You can either use a chain of #if...#else #if...#else statements,
>> or you can switch to using numbers instead of letters.
>
>You might do the latter using the asc() function:
>
>#switch(asc(Choice))
>    #case(asc("A"))
>    ...

Thanks Chriss, but I've already rewritten it to use all numbers, some how 
55 isn't as intuitive as E5, particularly when looking at the chess board
in fron of me. 

At the moment I'm just commenting each call to the macro // D4 just to help
me know where things are. 

--
Cheers
Steve              email mailto:ste### [at] zeroppsuklinuxnet

%HAV-A-NICEDAY Error not enough coffee  0 pps. 

web http://www.zeropps.uklinux.net/

or  http://start.at/zero-pps

 10:05pm  up 45 days, 9 min,  2 users,  load average: 1.05, 1.04, 1.01


Post a reply to this message

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