Hello Guest it is March 29, 2024, 11:36:38 AM

Author Topic: Mach4 Timer Script Error  (Read 939 times)

0 Members and 1 Guest are viewing this topic.

Mach4 Timer Script Error
« 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.
Code: [Select]
--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
 
« Last Edit: April 25, 2019, 03:59:18 PM by Tony Bullard »

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Mach4 Timer Script Error
« Reply #1 on: April 25, 2019, 04:11:47 PM »
take another look at your code

Code: [Select]
if timer == 0 then
timer(0)
elseif timer == 1 then
timer(1)

should be
Code: [Select]
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
New For 2022 - Instagram: dazthegas
Re: Mach4 Timer Script Error
« Reply #2 on: April 25, 2019, 04:23:53 PM »
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.