Machsupport Forum

G-Code, CAD, and CAM => G-Code, CAD, and CAM discussions => Topic started by: rcaffin on May 29, 2022, 06:46:27 AM

Title: Subroutine Library in Mach3
Post by: rcaffin on May 29, 2022, 06:46:27 AM
Has anyone tried to implement an external subroutine library with Mach3?

It would have to be invoked via something like m98 (-c:\dir\filename), and the actual subroutine in the library addressed by a passed variable along the lines of m98 p##1.

I believe it is theoretically possible, but I know the stack space in Mach3 is a shade limited.

Cheers
Roger
Title: Re: Subroutine Library in Mach3
Post by: BR549 on May 31, 2022, 09:18:59 PM
HIYA Roger, You can do that now with mach3. You call the sub from a remote directory with M98.

I will have to look up the details but it should be in the manual.
Title: Re: Subroutine Library in Mach3
Post by: BR549 on May 31, 2022, 09:52:00 PM
Put your Sub program into the subprograms folder then Call the sub with

Sub name = testsub.tap

M98 (testsub.tap) L1
Title: Re: Subroutine Library in Mach3
Post by: rcaffin on May 31, 2022, 09:59:03 PM
Oh yes, you can do that all right.

What I wanted to do was to load the whole library in with an m98 and to then call individual routines from within the library. I doubt that Mach3 can handle that.
But there is a way if the 'library' you call in starts with another call: m98 p##1, using #1 as the vector.
Devious. But I have done it a few times.
I have also implemented an array that way.

Hum - I wonder whether a sub in the called-in file can call back to the original program? I was able to do that with the stock overlay handler on a 16 bit machine, but one did have to be careful. What fun!

Cheers
Title: Re: Subroutine Library in Mach3
Post by: rcaffin on May 31, 2022, 10:01:05 PM
The sub does not have to be in the subroutine folder. It can be anywhere if you call it thus:
m98 (-c:\dir\file)

Cheers
Roger