Expression Syntax Error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Expression Syntax Error

Mathieu
Hi,
I try to use the command lines but have an "Expression Syntax Error". Here is the code :

c=10
d=\c+\c
po
\d,\d

and the answer of the command line is that one :

\c+\c,\c+\c
Expression Syntax Error

I don't know why it does not work because the following codes work :

a=5
po
\a,\a

b=5+5
po
\b,\b

If anyone can find the problem with my syntax, I would be so glad

Thanks,
have a nice day,
Mathieu.
Reply | Threaded
Open this post in threaded view
|

Re: Expression Syntax Error

LordOfBikes
Administrator
Hi Mathieu,

this is a nice find.
I even wasn't aware, that your working example is possible.
Where is your knowledge abut this syntax from?
If it is a LibreCAD site, we should possibly clarify this.

This functionality in LibreCAD is provided by the muparser library.
Because there was no update of muparser and no changes on the muparser implementation, I must assume, that this advanced using of the command line was never used before.

From my tests, I assume the problem is not muparser, but its implementation in LibreCAD.
I think the implementation is missing a recursive parsing of tokens.
Now the variable d becomes a simple string "\c+\c" which leads to the syntax error in expansion of \d.

So I see no workaround for this issue now. It needs a revamp of the muparser implementation.

The only reason I see behind the intention of your example is a kind of creating parametric drawings.
So what you can try is to make a spreadsheet with the formula parts and export a command file with absolute numbers.
There is a wiki article about this: https://wiki.librecad.org/index.php?title=Pseudo-Scripting_With_Excel

Armin
investing less than half an hour into Search function can save hours or days of waiting for a solution
Reply | Threaded
Open this post in threaded view
|

Re: Expression Syntax Error

Mathieu
Hi Armin,
thanks for your answer. I found the informations about command lines using variables on that webpage : https://librecad.readthedocs.io/en/latest/guides/cmdline.html
It is written that "Multi-command input can be assigned to a variable and variables can also contain other variables (they are read recursively)" but it seems it doesn't work with calculs. Fortunately you suggest the spreadsheet alternative which will be very helpful to use variables and calculs with the command line.
Thanks you very muche,
have a nice day,
Mathieu.