Page 1 of 1

How to create a timer ?

Posted: Sun Jan 07, 2018 2:30 am
by Blayde
Help. I feel stuck and stupid. :lol:

I need a timer to read value (constantly).

al = getAddressList()
mr = al.getMemoryRecordByDescription("Description here")
CEEditBox.Text = mr.Value

Re: How to create a timer ?

Posted: Sun Jan 07, 2018 4:08 am
by TheyCallMeTim13

Code: Select all

--------
-------- Timer
--------
local aTimer = nil
local aTimerInterval = 10
local aTimerTicks = 0
local aTimerTickMax = 0
local function aTimer_tick(timer)
	if aTimerTickMax > 0 and aTimerTicks >= aTimerTickMax then
		timer.destroy()
	end
	aTimerTicks = aTimerTicks + 1
	-- body
end
aTimer = createTimer(getMainForm(), false)
aTimer.Interval = aTimerInterval
aTimer.OnTimer = aTimer_tick
aTimer.Enabled = true
Generated with: I2 CE Lua Script Template Generator

Re: How to create a timer ?

Posted: Sun Jan 07, 2018 3:20 pm
by FreeER
A simpler option might be to let CE handle it whenever it updates the memory record using OnGetDisplayValue

Code: Select all

al = getAddressList()
mr = al.getMemoryRecordByDescription("Description here")

mr.OnGetDisplayValue = function(mr,valuestring)
  --CETrainer.CEEdit1.Text = valuestring -- testing
  CEEditBox.Text = valuestring
end

Re: How to create a timer ?

Posted: Sun Jan 07, 2018 4:16 pm
by Blayde
FreeER wrote:
Sun Jan 07, 2018 3:20 pm
A simpler option might be to let CE handle it whenever it updates the memory record using OnGetDisplayValue

Code: Select all

al = getAddressList()
mr = al.getMemoryRecordByDescription("Description here")

mr.OnGetDisplayValue = function(mr,valuestring)
  --CETrainer.CEEdit1.Text = valuestring -- testing
  CEEditBox.Text = valuestring
end
Thanks.
I'll do some tests and report.


Edit:
Error

Code: Select all

al = getAddressList()
mr = al.getMemoryRecordByDescription("Description here")
mr.OnGetDisplayValue = function(mr,valuestring)
  --CETrainer.CEEdit1.Text = valuestring -- testing
  CEEditBox.Text = valuestring
end
Working

Code: Select all

al = getAddressList()
mr = al.getMemoryRecordByDescription("Description here")
mr.OnGetDisplayValue = function(mr,valuestring)
  CETrainer.CEEdit1.Text = valuestring -- testing
  --CEEditBox.Text = valuestring
end
Thank you