[imapfilter-devel] Re: iterate on defined filters
David DeSimone
fox at verio.net
Wed Aug 18 01:56:04 EEST 2004
Joel CARNAT <joel at carnat.net> wrote:
>
> spam = { 'subject "SPAM FROM"', }
> virus = { 'subject "VIRUS" "FROM"', }
>
> for ALERTS in {spam, virus} do
> print("ALERTS is " .. ALERTS)
> end
I think you want to use the "pairs" function to iterate over data in a
table, like so:
for k, ALERTS in pairs( {spam, virus} )
The "k" variable is the position in the table, which you can ignore, but
it is needed in order to get the value stored into ALERTS.
Note that here, ALERTS contains a TABLE, not a string value, so your
statement
print("ALERTS is " .. ALERTS)
will fail because you cannot concatenate a string with a table.
Of course, that is just a debug statement, so you could hack it like so:
print("ALERTS is " .. ALERTS[1])
Thus printing the first element from the table.
Note that you DO want ALERTS to be a table, because that is required by
the match() routine.
> PS: any good link to learn LUA (else than google_lua_tutorial :) ?
The online reference is quite useful:
http://www.lua.org/pil/index.html
--
David DeSimone || Network Admin || fox at verio.net
"It took me fifteen years to discover that I had no
talent for writing, but I couldn't give it up because
by that time I was too famous. -- Robert Benchley
More information about the Imapfilter-devel
mailing list