Problem using functions
-
@phaedrux This might be me doing something silly or missing something. I downloaded the macro file on my computer. Now I am trying to go to "upload file" and select the macro file, but it keeps saying invalid file format.
Also, the macro file contains only this line and no other text in it. I tried sending this same line using the console as well but I get a similar error:
Error: meta command: unknown value 'sin' -
@anagh said in Problem using functions:
var testValue = sin(50)
Being just curious: do you run your Duet in CNC mode?
-
@infiniteloop yes.
-
@anagh OK. I just had a look at the documentation, it says:
Sub-expressions may be enclosed in { } or in ( ). However, standard CNC GCode uses ( ) to enclose comments. So in CNC mode, RepRapFirmware treats ( ) as enclosing subexpressions when they appear inside { } and as enclosing comments when they do not. Therefore, when RepRapFirmware is running in CNC mode, any use of ( ) to enclose a subexpression or function parameter list must be within an expression enclosed in { }.
Try to enclose the expression in curly braces like this:
var testValue = { sin(50) }
-
@anagh said in Problem using functions:
but it keeps saying invalid file format.
What file extension does it have?
How did you create the file in the first place?
Can you test this macro?
-
@infiniteloop good catch
-
-
@phaedrux I created the file by going to the macros tab, then "New File" and then writing this line in the file.
I tested the macro you uploaded. Here is the error message:
M98 P"0:/macros/testsinmacro.g"
Error: in file macro line 1 column 17: meta command: unknown value 'sin' -
@phaedrux is running the machine in CNC mode an issue?
I still haven't been able to find a solution for this. I tried using math functions in macros and also sending them via the console. Both did not work. -
@anagh said in Problem using functions:
is running the machine in CNC mode an issue?
Sure you can ask @Phaedrux any question you want, but in this case, I had already posted the answer: CNC mode isn't an issue, but it is different. Round brackets are a special case, so you have to enclose your expressions in curly braces. Did my sample work?
I just entered the expression
echo {sin(50)}
into my console, and I'm pretty sure it works - notably: in CNC mode. The result is -0.2623748
-
@infiniteloop Sorry, I missed your earlier answer. Your solution works. Thanks a lot for your help.
-
-