Sorry if this has been hashed over, but I did a search and can’t seem to find quite what I’m looking for.
Which is… help with the syntax of the macro interface. I saw the postings, relating to how it’s basically JavaSccript (or Java), but when I tried a few basic things (like using a variable and displaying it) I had no joy. (just “bad number format”, no matter what I tried)
I can display the current xpos/ypos etc… but I don’t see much about how Java, interfaces with Gsender. (like variable creation, formatting it, displaying it, using it Gsender (like assign “variable” to xpos)).
I have a few basic Gcode only macros, like touch probe in the upper right corner, working, But it’s things like variables, that’s seems to be the issue.
Maybe just a link to a few working macros that create/use user variables?
One macro I’d like to make is one for probing a hole and returning the diameter, and perhaps one for a disk. That’s already out there, in Gcode, but not “grble” (since it doesn’t support trig or variables), and I haven’t seen one for Gsender.
So far, I’m liking it! Wish I could have found it sooner.
Thanks for that, I think it should help. A cursory read of a few macros, indicate I was doing it correctly, yet still getting an error. So I’ll have to zpend a bit more time with it.
I found that link to the LINUX Gcode, and book marked it. Lots of good information in there. Somewhere on that same site, talks about basically creating a height map. Which seems to be the same formate for Vetric’s 3D files.
The variables are part of macros in gSender. I have had trouble within gSender when adding comments at the end of a variable line. It must have something to do with parsing, so I just leave the comments off those lines.
Not sure what is going on. I kept getting “bad number format” or “expected command letter”.
Even after i typed the szme thing as in the sample macro (%TCA=…)
Tried some minor changes (cosmetic really) and now its working.
There must have been something in there it didnt like, like a space or blank line.
I hate that kind of stuff. I love it when I can see exactly what was causing the problem, but with these kinds of issues, I didnt really learn what it was.
Actually, I’m not sure what is going on. I can use variables, as in the posted sample macros. So, good there.
But the Gsender documentation I saw, says that the macros seem to use the Esprima interpreter (I guess), which is Java based. And using Java, seems to upset the macros. Even the sample code given as an example of Esprima usage, doesn’t work (%value=30 > 20) ? 10:20). Or a simple Java math function (such as abs(value) which returns the absolute value of a number) sienci doc
I would need the math functions, but I can live without that macro.
I’m more curious, did this change? or does the Esprima not really apply to macros the way I think it should (my mis reading the documentation). Maybe you have to insert a line to tell the console that it’s Esprima code?
Thanks for the macro, I’ll put it to use.
Hopefully, I plan on doing more with the maccros other than just that. Not sure what though, still learning, and seeing what I can do.
Sorry for the delayed response, it’s a busy time at Sienci with all the upcoming product launches.
Just popping in to points out we use Javascript, not Java.
So in your example, you’d need to use Math.abs(value) not abs().
%myVal=-1
([Math.abs(myVal)])
Ternarys also work, your given example:
%myVal=(30 > 20) ? 10 : 20
([myVal])
G0 X[myVal]
Generally the expression interpreter hasn’t been used too heavily past variables and simple math, but there’s definitely room to do some more complex things.
No user input - all parsing is done on the backend so you can’t use prompt. It’d have to be variables at the top of your macro that you change each time you have different inputs.
Hey @OldMicroguy, thanks for the feedback. I recently revised our gSender docs to have more guidance on how to make macros so let me know if you read it over and have any comments. I also linked Neils Macros and plan to set up a place to store gSender macros too: