Is MACH4 suspended while a SUB is running (as with MACH3 named SUBS) or is it still necessary to insert pauses/delays?
And as long as were on the topic, does MACH4 support named SUBS?
Mach 4 is not suspended. But I'm not sure what you mean.
And by named subs do you mean the sub file named in the comment? If so, then Mach 4 supports that.
Steve
Sorry for confusion. I tend to think of macros as subroutines and intermix the terms.
When I started modifying MACH3, macros could only be 'named' as 'M*********x'. When called from G-code, the MACH3 interpreter would pass the script execution to VBscript and then immediately move on to process the next G-code block. If the script was producing data used by subsequent G-code, the data might not be updated prior to the G-code block grabbing the data.
The only cure for this was to insert delays to give the VBscript time to execute before the G-code block needing the data was parsed by the MACH interpreter.
By 'named' I refer to scripts contained in external files having any legal windows file name instead of the restrictive 'M*********'. The behavior of RunScript differed in that MACH3 waited (suspended the g-code interperter) until the script returned before continuing to the next G-code block. Here is the description from the Programmer's reference
RunScript
Function RunScript(ByVal QFN as string) as Integer
This function can be used to run the script in the specified filename.
The qualified file name (QFN) parameter is relative to the Mach install directory.
The function will load the specified script file, compile it, execute it and return when the
script has completed.
Prior to the addition of this call, it was common practice to put script code into a
M*********.m1s macro, and use the Code call to execute the M********* macro. The execution of an
M********* macro involves the use of the Mach GCode interpreter (as what you are really doing is executing a GCode M word block) and can result in the programmer having to
invent and handle semaphores to coordinate the asynchronous execution of the M*********
macro.
It is recommended that the use of the Code “as a subroutine call method” be avoided and
that, when possible, the RunScript call should be used instead.y
First Mach3 version with API:
This API was first implemented in Mach3 version 3.43.06.
On 3.43.6 the API was defined as a Boolean function
Return Value:
True = Script was found and invoked.
False = Script was not found.
This API was revised in Mach3 version 3.43.19 to be an integer function.When this was implemented, I changed dozens of macros to this method and a lot of timing issues were eliminated and the system as a whole became more stable and reliable, particularly with complex rigid tapping macros. It gets ugly when MACH3 moves while the tap is still in the hole, for example.
So, with Lua replacing VBscript, how is the above described process handled by MACH4? Specifically, does MACH4 suspend the G-code execution until macros return or will the programmer still have to test and insert delays to assure this happens?
Secondly, will macros be able to have any legal windows file name and be called by a 'RunScript' (or equiv) call?