Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: Tony Bullard on April 25, 2019, 03:56:45 PM
-
I’d like to set up some Mach4 timers to control a lub pump.
I believe I’ve followed Daz’s tutorial https://www.youtube.com/watch?v=wNPMqjkcJ_8 correctly. I’ve set the Mach4 Timer Script, Screen Load Script and a Button Script. This is the code.
--Timer Script:
if timer == 0 then
timer(0)
elseif timer == 1 then
timer(1)
elseif timer == 2 then
timer(2)
elseif timer == 3 then
timer(3)
elseif timer == 4 then
timer(4)
elseif timer == 5 then
timer(5)
elseif timer == 6 then
timer(6)
elseif timer == 7 then
timer(7)
elseif timer == 8 then
timer(8)
elseif timer == 9 then
timer(9)
else
mc.mcCntlSetLastError(inst, 'Timer out of range')
end
--add TB 04-24-19
--Screen Load Script
function timer0() --This timer is called from "Test 2" button
wx.wxMessageBox("Hello From timer 0")
end
--Button Script:
scr.StartTimer(0,2000,1)
This is the error I get when the timer runs. Any suggestions as how to fix the error? Thanks for any help
-
take another look at your code
if timer == 0 then
timer(0)
elseif timer == 1 then
timer(1)
should be
if timer == 0 then
timer0()
elseif timer == 1 then
timer1()
your code is looking for a function called timer() and possing a value to it.
DazTheGas
-
Thank you Daz! I've been working on this all day and I just didn't see it. I feel kina bad asking for help when I should have been able to find the answer myself. Thank you again for all your help on these forums.