This is a perfect example of why you need to always keep the default screen. Also, I would highly recommend when you start with Mach4 copy the profile and screen you plan to start your actual profile with and save each of them as something custom, screen and profile. I usually make the names match for both screen and profile. This way later on you have a exact copy of what you began with if you need to undo something, use for reference, start over, etc.
The cycle timer uses 2 bits of script. One in the screens PLC script and the other is in the screens screen load script.
PLC
-------------------------------------------------------
-- Cycle time label update
-------------------------------------------------------
--Requires a static text box named "CycleTime" on the screen
if (machEnabled == 1) then
local cycletime = mc.mcCntlGetRunTime(inst, time)
scr.SetProperty("CycleTime", "Label", SecondsToTime(cycletime))
end
Screen load
-------------------------------------------------------
-- Seconds to time Added 5-9-16
-------------------------------------------------------
--Converts decimal seconds to an HH:MM:SS.xx format
function SecondsToTime(seconds)
if seconds == 0 then
return "00:00:00.00"
else
local hours = string.format("%02.f", math.floor(seconds/3600))
local mins = string.format("%02.f", math.floor((seconds/60) - (hours*60)))
local secs = string.format("%04.2f",(seconds - (hours*3600) - (mins*60)))
return hours .. ":" .. mins .. ":" .. secs
end
end