Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: HeadyCS on December 25, 2018, 04:09:47 AM

Title: Define own global Variables to use in macros
Post by: HeadyCS on December 25, 2018, 04:09:47 AM
In the "screen load script" I would like to define my own global variables and functions that are also available in macro scripts (m6).

I tried it with the following variables
myOwnVariable = 1;
mc.myOwnVariable = 1;

but in m6 script these are not available. when calling the scripts is executed up to this point and then the script aborted. I do not see any error message like "m6, line55: attempt to compare nil with string". Is there a log file in which such errors are written?
Title: Re: Define own global Variables to use in macros
Post by: joeaverage on December 25, 2018, 06:27:23 AM
Hi,
the screen load script is in the GUI 'chunk' whereas the m6 macro is in the Gcode interpreter 'chunk'.

A variable in one chunk is not available in the other.

There is a way to pass data between chunks......use registers. In the Docs folder:

Quote
Mach4 CNC Controller
Lua Scripting Guide
Section 4 from page 14.

Craig