|
|
|
|
|
|
| |
| |
|
|
|
|
| |
| |
|
|
When I try to compile the following code, it says there should be a ) after X+1.
Am I doing this right? It's supposed to return X+1 if Dir = 0 or 1, X if it's 2
or 5, and X-1 if it's 3 or 4.
#macro NextX(X,Dir)
#switch(Dir)
#case(0)
#case(1)
X+1
#break
#case(2)
X
#break
#case(3)
#case(4)
X-1
#break
#case(5)
X
#break
#end
#end
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Archpawn" <nomail@nomail> wrote:
> When I try to compile the following code, it says there should be a ) after X+1.
> Am I doing this right? It's supposed to return X+1 if Dir = 0 or 1, X if it's 2
> or 5, and X-1 if it's 3 or 4.
> #macro NextX(X,Dir)
> #switch(Dir)
> #case(0)
> #case(1)
> X+1
> #break
> #case(2)
> X
> #break
> #case(3)
> #case(4)
> X-1
> #break
> #case(5)
> X
> #break
> #end
> #end
I think you need to specify where the returned value is to be stored:
#macro NextX(X,Dir)
#switch(Dir)
#case(0)
#case(1)
#declare RetXVal = X+1;
#break
#case(2)
#declare RetXVal = X;
#break
#case(3)
#case(4)
#declare RetXVal = X-1;
#break
#case(5)
#declare RetXVal = X;
#break
#end
#end
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
> When I try to compile the following code, it says there should be a )
> after X+1.
> Am I doing this right? It's supposed to return X+1 if Dir = 0 or 1, X if
> it's 2
> or 5, and X-1 if it's 3 or 4.
#macro NextX(X,Dir)
#switch(Dir)
#range(0,1)
#local result = X+1;
#break
#case(2)
#local result = X;
#break
#range(3,4)
#local result = X-1;
#break
#case(5)
#local result = X;
#break
#end
(result)
#end
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Oh, and #case doesn't need to be in order...
#macro NextX(X,Dir)
#switch(Dir)
#range(0,1)
#local result = X+1;
#break
#range(3,4)
#local result = X-1;
#break
#case(2)
#case(5)
#local result = X;
#break
#end
(result)
#end
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Mike the Elder" <nomail@nomail> wrote:
> I think you need to specify where the returned value is to be stored:
> ...
On http://www.povray.org/documentation/view/3.6.1/243/ , it gives the example
#macro Interpolate(T,T1,T2,P1,P2)
(P1+(T1+T/(T2-T1))*(P2-P1))
#end
Which essentially replaces Interpolate(T,T1,T2,P1,P2) with
(P1+(T1+T/(T2-T1))*(P2-P1)).
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
"Archpawn" <nomail@nomail> wrote in message
news:web.47b0ded4bd25e05c9c37dbc40@news.povray.org...
> When I try to compile the following code, it says there should be a )
> after X+1.
> Am I doing this right? It's supposed to return X+1 if Dir = 0 or 1, X if
> it's 2
> or 5, and X-1 if it's 3 or 4.
> #macro NextX(X,Dir)
> #switch(Dir)
> #case(0)
> #case(1)
> X+1
> #break
> ... snip ...
I cut and pasted your macro into a new empty file and added the one line
#debug concat("AAAAA: ",str(NextX(1,0),3,0),"\n")
I ran it with a couple of different parameters and it worked as expected
(Black image, but a number returned to the message stream).
Are you sure you don't have an error in the main body of your code?
If you've got an open bracket out of place before any of the macro
invocations, then that would explain the message.
Regards,
Chris B.
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |
| |
|
|
Mike the Elder <nomail@nomail> wrote:
> #macro NextX(X,Dir)
> #switch(Dir)
> #case(0)
> #case(1)
> #declare RetXVal = X+1;
> #break
> #case(2)
> #declare RetXVal = X;
> #break
> #case(3)
> #case(4)
> #declare RetXVal = X-1;
> #break
> #case(5)
> #declare RetXVal = X;
> #break
> #end
> #end
No, not like that. Use #local and put the identifier name at the end
of the macro.
--
- Warp
Post a reply to this message
|
|
| |
| |
|
|
|
|
| |