[PD] pdlua output

Frank Barknecht fbar at footils.org
Wed Jan 30 17:30:23 CET 2008


Hallo,
robcanning hat gesagt: // robcanning wrote:

> ok, so this code finds all the scores with a value greater than one and 
> sends them to outlet one when given the message [greaterthan(
> 
> 
> function M:in_1_greaterthan()
> for i, v in ipairs(self.mydata) do
>   if tonumber(string.match(table.concat(v, " "), "score=(%d+)")) > 1
> then self:outlet(1, "", v) end
> end
> end
> 
> now i want to be able to send the message [greaterthan score 3(
> 
> so in the code where it says "score=(%d+)")) - i need "score" to be 
> variable from second part of the message  the ">1" needs to be a 
> variable from the 3rd part of the message
> 
> i know its somewhere within the () below but i cant seem to get it right
> function M:in_1_greaterthan()

Okay, now function M:in_1_greaterthan() needs to accept additional
data. This gets passed as an argument to the function. Arguments are
wrapped in a table in pdlua. In the following I called that table
"args", but you can call it anything. Then "args" is concatenated into
a single search string.

 function M:in_1_greaterthan(args)
     searchstring = table.concat(args, " ")
     for i, v in ipairs(self.mydata) do
       if tonumber(string.match(table.concat(v, " "), searchstring)) > 1
     then self:outlet(1, "", v) end
     end
 end


Ciao
-- 
 Frank Barknecht                                     _ ______footils.org__




More information about the Pd-list mailing list