Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: mcardoso on April 24, 2019, 09:20:58 AM

Title: Can I create an Library of functions outside the Screen Load Script?
Post by: mcardoso on April 24, 2019, 09:20:58 AM
I have 30 or so custom functions that I wrote to interface over serial with some servo drives. Each one reads or writes a unique piece of data such as servoGetPositon(). These are taking up a lot of space in my screen load script and I would like to move them somewhere else to maintain readability without changing the functionality.

I am not a programmer so the phrasing I'm going to use is probably wrong, but is there a way to save all these functions in a "library file" and "include" this at the top of the screen load script? something like #include "servoScript.h" from C++? Does Mach/LUA support this?

Thanks!
Title: Re: Can I create an Library of functions outside the Screen Load Script?
Post by: joeaverage on April 24, 2019, 12:06:15 PM
Hi,
I think a module is what is required.

https://www.machsupport.com/forum/index.php?topic=35007.0 (https://www.machsupport.com/forum/index.php?topic=35007.0)

Craig
Title: Re: Can I create an Library of functions outside the Screen Load Script?
Post by: mcardoso on April 24, 2019, 01:45:58 PM
Thanks!

I'm going to have to watch that about 10 times to get it, but that looks perfect!
Title: Re: Can I create an Library of functions outside the Screen Load Script?
Post by: mcardoso on April 25, 2019, 10:30:44 PM
Converted all my custom functions to modules. Took a little effort but well worth it. Functionality has not changed (that's what I wanted)