POV-Ray : Newsgroups : povray.general : syntax error with macro Server Time
1 Nov 2024 17:21:54 EDT (-0400)
  syntax error with macro (Message 1 to 6 of 6)  
From: kurtz le pirate
Subject: syntax error with macro
Date: 2 May 2011 10:05:09
Message: <kurtzlepirate-BD0D5F.16050802052011@news.povray.org>
hello,

i have this simple macro :

#macro lineEquation (x1,z1,x2,z2)
  #local det = x1-x2;
  #if(det=0)
    #error "\n\n---\nWarning, the system has no unique 
solution.\nProgram stop here\n\n"
  #else
    #local det_a = z1-z2;
    #local det_b = (x1*z2)-(z1*x2);
    <det_a/det, det_b/det, 0>
  #end
#end


i call this with this syntax :

#declare sidesLines[0][0] = 
lineEquation(rectangles[0][0].x,rectangles[0][0].z,rectangles[0][1].x,rec
tangles[0][1].z); // with ';' at the end of the line.


arrays "rectangles" and "sidesLines" are defined in this way :

#declare nbRect=1;
#declare rectangles = array[nbRect][4];
#declare sidesLines = array[nbRect][4];



when i run my script, i get this error :

File Context (5 lines):
  #else
    #local det_a = z1-z2;
    #local det_b = (x1*z2)-(z1*x2);
    <det_a/det, det_b/det, 0>
  #
Parse Error: All #declares of float, vector, and color require 
semi-colon ';' at end if the language version is set to
 3.5 or higher. Either add the semi-colon or set the language version to 
3.1 or lower.



where is my mistake ?

-- 
klp


Post a reply to this message

From: Alain
Subject: Re: syntax error with macro
Date: 2 May 2011 14:22:06
Message: <4dbef64e@news.povray.org>

>
> hello,
>
> i have this simple macro :
>
> #macro lineEquation (x1,z1,x2,z2)
>    #local det = x1-x2;
>    #if(det=0)
>      #error "\n\n---\nWarning, the system has no unique
> solution.\nProgram stop here\n\n"
>    #else
>      #local det_a = z1-z2;
>      #local det_b = (x1*z2)-(z1*x2);
>      <det_a/det, det_b/det, 0>
>    #end
> #end
>
>
> i call this with this syntax :
>
> #declare sidesLines[0][0] =
> lineEquation(rectangles[0][0].x,rectangles[0][0].z,rectangles[0][1].x,rec
> tangles[0][1].z); // with ';' at the end of the line.
>
>
> arrays "rectangles" and "sidesLines" are defined in this way :
>
> #declare nbRect=1;
> #declare rectangles = array[nbRect][4];
> #declare sidesLines = array[nbRect][4];
>
>
>
> when i run my script, i get this error :
>
> File Context (5 lines):
>    #else
>      #local det_a = z1-z2;
>      #local det_b = (x1*z2)-(z1*x2);
>      <det_a/det, det_b/det, 0>
>    #
> Parse Error: All #declares of float, vector, and color require
> semi-colon ';' at end if the language version is set to
>   3.5 or higher. Either add the semi-colon or set the language version to
> 3.1 or lower.
>
>
>
> where is my mistake ?
>
Try this:
<det_a/det, det_b/det, 0>;



Alain


Post a reply to this message

From: kurtz le pirate
Subject: Re: syntax error with macro
Date: 3 May 2011 13:11:41
Message: <kurtzlepirate-8158DA.19114003052011@news.povray.org>
In article <4dbef64e@news.povray.org>, Alain <aze### [at] qwertyorg> wrote:

> Try this:
> <det_a/det, det_b/det, 0>;


already tried...

error is now :

File Context (5 lines):
// --- z = ax + b
// --- line d0 : p0 to p1
#declare sidesLines[0][0] = 
lineEquation(rectangles[0][0].x,rectangles[0][0].z,rectangles[0][1].x,rec
tangles[0][1].z);
Parse Error: Expected 'object or directive', ; found instead




-- 
klp


Post a reply to this message

From: Jaime Vives Piqueres
Subject: Re: syntax error with macro
Date: 3 May 2011 13:19:19
Message: <4dc03917$1@news.povray.org>

>
> hello,
>
> i have this simple macro :
>
> #macro lineEquation (x1,z1,x2,z2) #local det = x1-x2; #if(det=0)
> #error "\n\n---\nWarning, the system has no unique solution.\nProgram
> stop here\n\n" #else #local det_a = z1-z2; #local det_b =
> (x1*z2)-(z1*x2); <det_a/det, det_b/det, 0> #end #end
>

   I seem to recall something similar happening to me... I think it was
due to the return value being not declared and inside an "if". Try this:

#macro lineEquation (x1,z1,x2,z2)
    #local det = x1-x2;
    #if(det=0)
      #error "\n\n---\nWarning, the system has no unique
solution.\nProgram stop here\n\n"
    #else
      #local det_a = z1-z2;
      #local det_b = (x1*z2)-(z1*x2);
      #local result=<det_a/det, det_b/det, 0>;
    #end
    result
#end


-- 
Jaime Vives Piqueres
		
La Persistencia de la Ignorancia
http://www.ignorancia.org


Post a reply to this message

From: Trevor G Quayle
Subject: Re: syntax error with macro
Date: 3 May 2011 15:20:00
Message: <web.4dc0547bc5c3a7fb81c811d20@news.povray.org>
kurtz le pirate <kur### [at] yahoofr> wrote:
> In article <4dbef64e@news.povray.org>, Alain <aze### [at] qwertyorg> wrote:
>
> > Try this:
> > <det_a/det, det_b/det, 0>;
>
>
> already tried...
>
> error is now :
>
> File Context (5 lines):
> // --- z = ax + b
> // --- line d0 : p0 to p1
> #declare sidesLines[0][0] =
> lineEquation(rectangles[0][0].x,rectangles[0][0].z,rectangles[0][1].x,rec
> tangles[0][1].z);
> Parse Error: Expected 'object or directive', ; found instead
>
>
>
>
> --
> klp

Remove the ';' from this declaration now:

#declare sidesLines[0][0] =
lineEquation(rectangles[0][0].x,rectangles[0][0].z,rectangles[0][1].x,rec
tangles[0][1].z)


It does have something to do with the result being posted inside the #if loop.
The other alternative and what I would see as the cleaner, more correct
alternative, is to move the value outside the #if loop:


#macro lineEquation (x1,z1,x2,z2)
  #local det = x1-x2;
  #if(det=0)
    #error "\n\n---\nWarning, the system has no unique solution.\nProgram stop
here\n\n"
  #else
    #local det_a = z1-z2;
    #local det_b = (x1*z2)-(z1*x2);
  #end
  <det_a/det, det_b/det, 0>
#end

#declare sidesLines[0][0] = lineEquation(,,,);


-tgq


Post a reply to this message

From: clipka
Subject: Re: syntax error with macro
Date: 9 May 2011 06:32:11
Message: <4dc7c2ab$1@news.povray.org>
Am 02.05.2011 16:05, schrieb kurtz le pirate:

> i have this simple macro :
>
> #macro lineEquation (x1,z1,x2,z2)
>    #local det = x1-x2;
>    #if(det=0)
>      #error "\n\n---\nWarning, the system has no unique
> solution.\nProgram stop here\n\n"
>    #else
>      #local det_a = z1-z2;
>      #local det_b = (x1*z2)-(z1*x2);
>      <det_a/det, det_b/det, 0>
>    #end
> #end

For some obscure reasons, POV-Ray has some problems with assigning 
macro-generated expressions to variables. Try using:

  #macro lineEquation (x1,z1,x2,z2)
    #local det = x1-x2;
    #if(det=0)
      ...
    #else
      #local det_a = z1-z2;
      #local det_b = (x1*z2)-(z1*x2);
      #local result = <det_a/det, det_b/det, 0>;
      result
    #end
  #end


Post a reply to this message

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