Is there really no better way of writing macros?

This is where you talk about Macros, show examples of your macro scripting and SHARE handy segments of script code as examples.

Is there really no better way of writing macros?

Postby A_Camera » Sun Sep 25, 2016 1:41 pm

Am I missing something? Do I really have to use Notepad to edit macro script? I mean, that is EXTREMELY primitive and the debug possibilities are ZERO, making it very difficult to write macros which are a bit longer and more complex.

Also, when there is an error in a macro and I try to run that macro because I have no idea that there is a bug in it all I get for information is that "Script error: M3 has an error(s) and can not execute." No information about line number or anything in particular. Is there a file where there is more information to get from, or is there something I am missing?

Anybody have any tips on useful tools? I know Mach3 was not that great regarding macro editing and one could write over important macro files by accident very easy, but with some discipline it worked pretty well. Unfortunately, it works only for VB, so it is of no help, but it would be great to have at least something similar to that, with the possibilities of stepping through a macro and some syntax checking to be able to perform some debugging.
A_Camera
 
Posts: 639
Joined: Tue Sep 20, 2016 11:37 am

Re: Is there really no better way of writing macros?

Postby Robertspark » Sun Sep 25, 2016 2:49 pm

I use notepad++ https://notepad-plus-plus.org/download/v7.html
I select C# as the language and edit away, it provides tips / automatic fill suggestions.

For tracing problems what I do is use comments
"//"

and multiline comments
"/*" .... "*/"

and I break my code down into chunks and that way find out where my problem lies.

syntax is a common error when you first start with c# (forgetting the " ; " at the end of the line) also matched typecase.

Unless you're precious about your macro codes, I'd suggest posting the code on here and I'm happy to try to faultfind for you (or someone else will) .... bit of an explanation of what you're trying to do is helpful, hence I comment out my code a lot (but then it's nice to know what on earth I was thinking in 6-months / a year +)
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Is there really no better way of writing macros?

Postby Robertspark » Sun Sep 25, 2016 3:01 pm

You can add a g-code lanuguage syntax to notepad++

I think this is the one I used (but have a search of the net if you want something else):
https://github.com/robEllenberg/gcode-syntax

I use notepad++ a lot, when you get use to it you get the benefit of multiple tabs and other stuff like you can close it and it will keep your current worked on (unsaved files) for next restart, also if you are reading g-code and re-run the post processor which updates it a message pops up to ask if you want to update the file as its changed
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Is there really no better way of writing macros?

Postby A_Camera » Sun Sep 25, 2016 4:31 pm

OK, thanks. Notepad++ is better than Notepad, but that's not what I meant. Yes, I also comment lines I suspect has the errors, but compared to the tools I am used to, this is EXTREMELY primitive and time consuming.

I have all my current macros working, but right now have only written three, M3, M4 and M5 but it took more than it should have taken considering the few lines and that M3 and M4 are basically copy and paste. What I am fearing is my referencing macros, I have quite a few different ones in Mach3 VB and all those must be converted before I can start using UCCNC seriously.
A_Camera
 
Posts: 639
Joined: Tue Sep 20, 2016 11:37 am

Re: Is there really no better way of writing macros?

Postby Robertspark » Sun Sep 25, 2016 5:06 pm

If you are not precious about them, post them on here and I'll do them for you if I can or you can email them.

I never thought Mach was advanced at macro writing

What would you like.... I may try to sort out a notepad++ plugin for uccnc macros to help with the standard codes (saves copying it out of the macro compatibility documentation file...)

Also, if you copy the exec.code("ccccc") out of the macro compatibility document the speech marks are wrong and won't work...)
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Is there really no better way of writing macros?

Postby A_Camera » Sun Sep 25, 2016 7:50 pm

Robertspark wrote:If you are not precious about them, post them on here and I'll do them for you if I can or you can email them.

OK, thanks, but I'll give it a try myself.

Robertspark wrote:I never thought Mach was advanced at macro writing


I didn't say it was advanced, but compared to UCCNC it is indeed better.

Robertspark wrote:What would you like.... I may try to sort out a notepad++ plugin for uccnc macros to help with the standard codes (saves copying it out of the macro compatibility documentation file...)

Also, if you copy the exec.code("ccccc") out of the macro compatibility document the speech marks are wrong and won't work...)


I simply wish there was a better, built in tool in UCCNC. That's it. Some support for debugging, and at least an intelligent message saying something similar to "Script error: M3 has an error(s) on line 5 and can not execute." Not just a simple "Good bye and good luck with the rest of the code", as it is today. That's pretty nasty, because the code just continues like if nothing happened, so it might even crash your machine if something goes wrong.
A_Camera
 
Posts: 639
Joined: Tue Sep 20, 2016 11:37 am

Re: Is there really no better way of writing macros?

Postby Robertspark » Mon Sep 26, 2016 5:53 am

I've nearly completed the notepad++ style + autocomplete with tool tips for the functions (just adding the tool tips and I'll upload it for anyone who wants it, plus comments to add any other functions for the autocomplete)

If you are doing wizard type macros with forms, this is probably best done in visual studio and then copy and paste the layout code into the macro file as visual studio will add all the controls and formatting and control position coordinates
Robertspark
 
Posts: 1892
Joined: Sat Sep 03, 2016 4:27 pm

Re: Is there really no better way of writing macros?

Postby A_Camera » Mon Sep 26, 2016 6:24 am

Vmax549 wrote:When you see an error when testing macro code go to the active Macro folder and look at teh ERRORLOG.txt file. THAT is teh debug message file . Once you get to know it it does give you a LOT of debug info. UCCNC HAS talked about a new debugger for teh future. But for now this one does work fairly well.

What I normal do now is open notepad++ and open teh macro and open teh errolog file in a split window.

OR sometimes I do about the same thing with notepad and open teh 2 files.

(;-) TP

Thanks. That's very good to know and that was about what I was looking for as well. Now just need the ability to step, jump in, skip, watch variables... :D

Anyway, it is definitely better than without any help.
A_Camera
 
Posts: 639
Joined: Tue Sep 20, 2016 11:37 am


Return to Macros

Who is online

Users browsing this forum: No registered users and 12 guests