Hello Guest it is May 12, 2021, 08:54:27 PM

Author Topic: M code macros do not run  (Read 2663 times)

0 Members and 1 Guest are viewing this topic.

M code macros do not run
« on: September 20, 2017, 05:21:50 PM »
Hi,

this might be a trivial issue but I cannot figure it out. Mach4 ignores all mcs files in my C:\Mach4Hobby\Profiles\QR\Macros\ (profile name is QR). Bottom of wxMach screen shows active profile QR.

I created m111.mcs for testing with this content:
Code: [Select]
function m111()
wx.wxMessageBox( "here" )
end

if (mc.mcInEditor() == 1) then
m111()
end
After running m111 from MDI nothing happens.


I copied m111.mcs to \Profiles\Mach4Mill\Macros, loaded Mach4Mill profile and the macro works. Mach4 upon startup also compiled mcs files in folder and corresponding mcc files appeared in the same folder. This does not happen with my QR profile.

Please, can you advice how to fix this? It looks like it is related only to my custom profile.


Thanks.


Boris


Best regards
Boris
Re: M code macros do not run
« Reply #1 on: September 20, 2017, 06:02:14 PM »
Hi,
your file should be in the macros folder of YOUR profile.

Craig
My wife left with my best friend...
     and I miss him!
Re: M code macros do not run
« Reply #2 on: September 21, 2017, 01:12:48 AM »
Hi Craig,

as I wrote, "Mach4 ignores all mcs files in my C:\Mach4Hobby\Profiles\QR\Macros\ (profile name is QR)", this is not the issue.

Other ideas?

Thanks.


Boris

Re: M code macros do not run
« Reply #3 on: September 21, 2017, 02:51:57 AM »
Hi,
well that's a different problem altogether and I don't think I'm going to be able to help.

It occurred to me after posting my reply to you this morning that if you go Operator/Edit-Debug scripts the list of scripts in your profile will be displayed,
a very simple test to prove that the file has been placed correctly.

As you probably know all the LUA fragments including your scripts get compiled and put together in one big LUA chunk at run time. If for whatever reason the
script didn't compile then it wouldn't end up in the chunk and wouldn't run if you called it. Does that describe whats happening? If so you could probably check
that it does compile without error. How you check whether it gets included in the chunk I don't know...hopefully someone will chime in with an explanation.

Craig
My wife left with my best friend...
     and I miss him!
Re: M code macros do not run
« Reply #4 on: September 21, 2017, 03:12:43 AM »
if you go Operator/Edit-Debug scripts the list of scripts in your profile will be displayed, a very simple test to prove that the file has been placed correctly.

First, I loaded default unmodified Mach4Mill profile. Operator/Edit-Debug scripts menu item opened a file selection dialog window showing content of C:\Mach4Hobby\Profiles\Mach4Mill\Macros folder.
When I selected my testing macro named m111.mcs, mcLua editor opened and I could successfully compile and debug my macro.

Then, I loaded my profile named "QR". Operator/Edit-Debug scripts menu item opened file selection dialog window showing files in C:\Mach4Hobby\Profiles\QR\Macros.
Here comes the problem. When I select m111.mcs, mcLua editor does not open! Instead, Mach4 displays this message in status bar:
No script engine found for C:\Mach4Hobby\Profiles\QR\Macros\m111.mcs

Files m111.mcs placed in Mach4Mill\Macros and QR\Macros are the exact copies, with the same name, file extension and content.

Any idea?
« Last Edit: September 21, 2017, 03:14:19 AM by qwertysimo »
Re: M code macros do not run
« Reply #5 on: September 21, 2017, 03:22:27 AM »
I did another test. I deleted my Macros folder from C:\Mach4Hobby\Profiles\QR\ and copied Macros folder from C:\Mach4Hobby\Profiles\Mach4Mill\

The same problem, No script engine found for C:\Mach4Hobby\Profiles\QR\Macros\m111.mcs
Re: M code macros do not run
« Reply #6 on: September 21, 2017, 03:26:55 AM »
Hi,
not really. Sounds rather like the macro m111.mcs is where its supposed to be but the Lua editor is not enabled and therefore the script cant be opened.

The only thing I can think of is that the Gcode editor is not enabled in you QR profile. Go to Configure/Mach/General and upper right hand side is a text box
with the path to the Gcode file editor. Is it populated with a legitimate file editor?

Craig
My wife left with my best friend...
     and I miss him!
Re: M code macros do not run
« Reply #7 on: September 21, 2017, 03:29:13 AM »
Hi,
my profile on the laptop is:
Code: [Select]
C:\Mach4Hobby\gcedit
Craig
My wife left with my best friend...
     and I miss him!
Re: M code macros do not run
« Reply #8 on: September 21, 2017, 03:30:45 AM »
Craig, it is not the "G code file editor" issue! Meanwhile I found this:

Enable the mcLua plugin. 

Steve

After enabling the plugin, Operator/Edit-Debug scripts opens my script in mcLua editor as expected and all mcs files were compiled upon Mach4 startup.

Craig, Steve, thanks!
Re: M code macros do not run
« Reply #9 on: September 21, 2017, 03:34:38 AM »
Anyway, isnt it a bit strange?
Lua scripts assigned to on-screen buttons work OK even without the plugin enabled.
What is different with macros placed in Macros folder?