multiple counters running in an Applet
Hi,
is this possible?
what would be the notation to do that?
I've tried using a variable to initialise it but the moment I add a 2nd, the first stops running.
I've tried adding counters to a table and using table.key to initialise but same as above.
I can't see anything wrong with the above code, nor why two or more timers in the same applet isn't working for you. Can you expand and give an example where its failing?
If you are trying to wildcard match on an event you would be better off using a Filter and '*' or '>'.
Lets see what you are trying to do, it might be your approach could be better optimized.
Brett
Correction I can see something wrong with what you are attempting to do.
dev = string.match(loc, "dbzoo%.hal%.Locate:*%.(%a+)")
timer.dev = xap.Timer(lessen, myInt)
** timer.dev will create a variable called 'dev' in the timer table.
What you mean is :
timer[dev] = xap.Timer(lessen, myInt)
This will create a variable using the contents of DEV in the timer table.
----
If you are trying to have a TIMEOUT for each ENDPOINT you would be better of changing your design to have one REAPER function based on a timer and a TTL field that tracks for each endpoint how long its lived. This is the same design that I use for the JEENODE enpoints. See jeenode.lua#grimreaper
The bluenode.lua code also has a reaper in it you can examine.
Brett
Perhaps by way of example this will be more clear:
[brett@wombat ~]$ lua
Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio
> a={}
> a.dev="hello"
> =a.dev
hello
> =a['dev']
hello
> b='dev'
> =a[b]
hello
>
Hi,
I haven't used multiple timers myself but the weather applet that Brett wrote in the samples directory does. Here's the code snippet: