Page 1 of 1

[Lua] Timer

Posted: Tue Apr 17, 2018 3:46 am
by UltimatePoto42

Code: Select all

--------
-------- Timer
--------
local aTimer = nil
local aTimerInterval = 100
local function aTimer_tick(timer)
    timer.destroy()
    -- body
end
aTimer = createTimer(MainForm)
aTimer.Interval = aTimerInterval
aTimer.OnTimer = aTimer_tick

Code: Select all

--------
-------- Timer
--------
local aTimer = nil
local aTimerInterval = 100
local aTimerTickMax = 5000
local aTimerTicks = 0
local function aTimer_tick(timer)
    if aTimerTickMax > 0 and aTimerTicks >= aTimerTickMax then
        timer.destroy()
    end
    aTimerTicks = aTimerTicks + 1
    -- body
end
aTimer = createTimer(MainForm, false)
aTimer.Interval = aTimerInterval
aTimer.OnTimer = aTimer_tick
aTimer.Enabled = true

Code: Select all

{$lua}
------------------------------ ENABLE ------------------------------
[ENABLE]
local aTimer = nil
local aTimerInterval = 100
local function aTimer_tick(timer)
    -- body
end
----------------------------------
if syntaxcheck then return end
aTimer = createTimer(MainForm)
aTimer.Interval = aTimerInterval
aTimer.OnTimer = aTimer_tick
------------------------------ DISABLE ------------------------------
[DISABLE]
if syntaxcheck then return end
aTimer.destroy()