[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ion
Subject:    Re: ? WMessage, getting external values, using extra parameters.
From:       tuomov () modeemi ! cs ! tut ! fi (Tuomo Valkonen)
Date:       2004-07-09 1:32:35
Message-ID: 20040709013235.GA10633 () jolt ! modeemi ! cs ! tut ! fi
[Download RAW message or body]

On Thu, Jul 08, 2004 at 11:51:11PM +0200, miGlanz wrote:
> kpress(SECOND_MOD.."F1", function(scr)
> 	popen_bgread("/home/kamil/.ion2/mailstat.sh",
> 		function (data)
> 			newmail = string.sub(data,string.find(data,"%d*"))
> 			oldmail = string.sub(data,string.find(data,"%d*")+1)
> 			query_message(scr, os.date() .. "\nNumber of new messages: " .. newmail .. \
> "\nNumber of read messages: " .. oldmail)  end)
> 	end),

Note that the size of 'data' is arbitrary. To do this "correctly", you
should collect new data until a nil 'data' is passed or you reach other
criterion to stop collecting. For example:

coroutine.wrap(function(s)
                   local cs=""
                   while s do
                       cs=cs..s
                       s=coroutine.yield()
                   end

                   -- now work on cs
               end)


Of course, it may be good to put limits on the size of 'cs', as the 
routines in querylib have.    

-- 
Tuomo


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic