Macro syntax/language help

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.

Here’s a couple of my public macros. You might get an idea or two from them. Also, here’s a link to some gcode definitions that address variables.

Gcode Definitions

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.

That seems to be my issue…

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.

Thamks for the help.

1 Like

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?

I’ve not tried to create anything more than macro code.

Perhaps if we notify @KGN ?

Possible, but as a nooby, I don’t know who that is… :smiley:

Does anybody from Siency monitor these threads?

Kevin is one of the developers for Sienci. Be patient.

1 Like

Ha! You should hear my wife regarding my patience, not one of my strong suits.

But we’re good. I’m in no hurry. (I have to rebuild Z-axis anyway, bad bearing)

You just want a macro to measure the diameter of a hole?
I use that in some simple macros here (one example).

I also have some that use three points on the circle, but I can’t locate them now.

1 Like

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().



Ternarys also work, your given example:

%myVal=(30 > 20) ? 10 : 20
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.

That’s OK, been busy myself, more so than I’d like to be…

That makes a big difference, I’ll check it out and see what I come up.

Thanks for the clarification.

One question about that though.

How deep is the use of JS?
Like, can I input variables? Or is I/O excluded?

That sort of thing. That’s really all I “think” I would like, input stuff like work piece size, without having to edit the macro first.

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.

Bummer, but that’s OK.
Thanks for the response.