471
Mach4 General Discussion / Re: Lua Macro Parameters
« on: March 07, 2017, 04:45:17 PM »
Chasing my tail again. 
I created a module 'rtModule.lua' in the modules folder
...
local rtModule = {}
function rtModule.rtMessage(msg)
wx.wxMessageBox(msg)
end
return rtModule
...
Added this to the screen load script under the load modules section
...
package.loaded.rtModule = nil
rt = require "rtModule"
...
I created, since none existed, a load_modules.mcs file and put it in the same macro folder as my profile macros 'C:\Mach4Hobby\Profiles\My4Lathe\Macros'
...
package.loaded.rtModule = nil
rt = require "rtModule"
...
Created a macro 'm9002.mcs' under the profile macros folder
...
function m9002()
rt.rtMessage('Another Hello')
end
if mc.mcInEditor()==1 then
m9002()
end
...
Added 2 buttons to the screen
btn1 leftup script
...
rt.rtMessage('Hello from a Button')
...
btn2 leftup script
...
inst=mc.mcGetInstance()
mc.mcCntlMdiExecute(inst,'m9002')
...
btn1 gives me the expected 'Hello from a Button'
btn2 does nothing
put m9002 in the mdi and press cycle start, nothing.
So I know that the rtModule.lua is getting loaded and functiong correctly.
Do I have a syntax error in the macro? Compiles.
Is there more to the load_modules.mcs that I am missing?
HELP!

I created a module 'rtModule.lua' in the modules folder
...
local rtModule = {}
function rtModule.rtMessage(msg)
wx.wxMessageBox(msg)
end
return rtModule
...
Added this to the screen load script under the load modules section
...
package.loaded.rtModule = nil
rt = require "rtModule"
...
I created, since none existed, a load_modules.mcs file and put it in the same macro folder as my profile macros 'C:\Mach4Hobby\Profiles\My4Lathe\Macros'
...
package.loaded.rtModule = nil
rt = require "rtModule"
...
Created a macro 'm9002.mcs' under the profile macros folder
...
function m9002()
rt.rtMessage('Another Hello')
end
if mc.mcInEditor()==1 then
m9002()
end
...
Added 2 buttons to the screen
btn1 leftup script
...
rt.rtMessage('Hello from a Button')
...
btn2 leftup script
...
inst=mc.mcGetInstance()
mc.mcCntlMdiExecute(inst,'m9002')
...
btn1 gives me the expected 'Hello from a Button'
btn2 does nothing
put m9002 in the mdi and press cycle start, nothing.
So I know that the rtModule.lua is getting loaded and functiong correctly.
Do I have a syntax error in the macro? Compiles.
Is there more to the load_modules.mcs that I am missing?
HELP!