[imapfilter-devel] print and unpack functions

Lefteris Chatzibarbas lefcha at hellug.gr
Thu May 27 23:58:01 EEST 2004


On Thu, May 27, 2004 at 10:55:59AM -0700, John Webster wrote:
> This works though. (Modified loop from sample.extend.lua file)
> 
> for msgid, msgtxt in pairs(text) do
>    print( msgtxt )
> end
> 
> --On Thursday, May 27, 2004 10:35:39 -0700 John Webster <jwebster at es.net> wrote:
> 
> > Imapfilter version 1.0
> > 
> > Does the output of print only go to debug?
> > I'm doing the following, but I'm not seeing
> > anything on stdout only in the debug file.
> > 
> > 
> > jw
> > 
> > 
> > -- filter
> > toMe = {
> >         'from "webster"',
> > }
> > 
> > -- commands
> > results = match(myaccount, 'INBOX', toMe)
> > text = fetchheader(myaccount, 'INBOX', results)
> > print( unpack (text) )

I think Lua's unpack() works with lists.  From the manual:

  unpack (list)

  Returns all elements from the given list. This function is equivalent
  to

    return list[1], list[2], ..., list[n]
  
  ...


Consider this example:

  foo = { 'qux', 'quux' }
  print(unpack(foo))

... prints:

  qux	quux

But:

  foo = {}
  foo[2] = 'qux'
  foo[5] = 'quux'
  print(unpack(foo))

... prints nothing.


If, for example, messages { 2, 5 } matched your filter, then only
text[2] and text[5] would be defined, and so unpack() does not return
their values.  OTOH, if messages { 1, 3 } matched your filter, then
unpack() would return only text[1] and since it cannot find text[2] it
would stop there.




More information about the Imapfilter-devel mailing list