<div dir="ltr"><div>[I see I was replying to Claude earlier. He says I shouldn't send proposed improvements to him alone, but to the list, in particular MrPeach, who maintains the distribution. So: ]<br><br></div>Adding a couple comments to the source (?), I suggest:<br>---------------------------------------------------------- <br><div><div>-- test receive support<br><br>local LReceive = pd.Class:new():register("lreceive")<br><br>function LReceive:initialize(name, atoms)<br>  if type(atoms[1]) ~= "string" then<br>    pd.post("lreceive needs a prefix for the receive names!")<br>    return false<br>  else<br>    self.prefix = atoms[1]<br>  end<br><b>  -- first of series of addresses to receive, from 'prefix..(atoms[2])' [default is 'prefix1']</b><br>  if type(atoms[2]) ~= "number" or atoms[2] < 1 then<br>    self.start = 1<br>  else<br>    self.start = math.floor(atoms[2])<br>  end<br>  <br> <b> -- to 'prefix..(n-atoms[3])'  (if atoms[3] is present && greater than 1.)</b><br>  if type(atoms[3]) ~= "number" or atoms[3] < 1 then<br>    self.count = 1<br>  else<br>    self.count = math.floor(atoms[3])<br>  end<br>  self.receives = { }<br>  self.inlets = 0<br>  self.outlets = 2<br>  return true<br>end<br><br>function LReceive:postinitialize()<br>  local i = 0<br>  while (i < self.count) do<br>    local n = self.start + i<br>    self.receives[i+1] = pd.Receive:new():register(self, self.prefix .. n, "receive_" .. n)<br>    self["receive_" .. n] = function (self, sel, atoms)<br>      self:outlet(2, "float", { n })<br>      self:outlet(1, sel, atoms)<br>    end<br>    i = i + 1<br>  end<br>end<br><br>function LReceive:finalize()<br>  for _,r in ipairs(self.receives) do r:destruct() end<br>end<br>----------------------------------------------------------------<br></div><div>and to lreceive:<br></div><div>------------------------------------------------<br>#N canvas 0 0 540 307 10;<br>#X obj 27 41 lreceive lreceive- 25 10;<br>#X obj 27 76 print lreceive-LEFT;<br>#X obj 190 76 print lreceive-RIGHT;<br>#X obj 26 252 send lreceive-25;<br>#X msg 26 196 foo bar 1 2 3;<br>#X msg 146 196 123 bar 1 2 3;<br>#X obj 146 252 send lreceive-27;<br>#X obj 272 252 send;<br>#X floatatom 295 204 5 24 35 2 n - -;<br>#X obj 295 226 makefilename lreceive-%d;<br>#X symbolatom 272 171 10 0 0 0 - - -;<br>#X obj 272 143 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144<br>-1 -1;<br><b>#X text 100 10 This example receives messages sent to 'lreceive-25' and the next 9 addresses up to 'lreceive-34', ie 10 addresses;</b><br>#X connect 0 0 1 0;<br>#X connect 0 1 2 0;<br>#X connect 4 0 3 0;<br>#X connect 5 0 6 0;<br>#X connect 8 0 9 0;<br>#X connect 9 0 7 1;<br>#X connect 10 0 7 0;<br>#X connect 11 0 10 0;<br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jul 4, 2015 at 10:07 AM, Claude Heiland-Allen <span dir="ltr"><<a href="mailto:claude@mathr.co.uk" target="_blank">claude@mathr.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Forrest,<div><div class="h5"><br>
<br>
On 04/07/15 17:43, Forrest Curo wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
When I use the example lreceive.pd_lua to produce [lreceive poo], it won't<br>
receive.<br>
<br>
Messages from [lsend poo] and [send poo] are both picked up by [r poo], but<br>
the lreceive just sits there.<br>
<br>
Anyone have a guess what's going on?<br>
</blockquote>
<br></div></div>
[lreceive] actually binds a number of receives, named with a prefix. For example:<br>
<br>
[lreceive poo 42 3]<br>
<br>
is more like<br>
<br>
[r poo42] [r poo43] [r poo44]<br>
 |         |         |<br>
[t a b]   [t a b]   [t a b]<br>
 | [42(    | [43(    | [44(<br>
 |  |      |  |      |  |<br>
(each pair is sent out from the 2 outlets of [lreceive])<br>
<br>
<br>
The start (here 42) and count (here 3) both default to 1, so just to test that it's working try [s poo1].<br>
<br>
Anyway, the examples I wrote weren't originally meant to be used as standalone objects (perhaps that was a mistake), but more as examples of how to use different parts of the pdlua API - you can read the source code of the .pd_lua examples (which are plain text) to guide you when writing your own objects, or just to see how they work.<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
Claude<br>
-- <br>
<a href="http://mathr.co.uk" rel="noreferrer" target="_blank">http://mathr.co.uk</a><br>
<br>
<br>
_______________________________________________<br>
<a href="mailto:Pd-list@lists.iem.at" target="_blank">Pd-list@lists.iem.at</a> mailing list<br>
UNSUBSCRIBE and account-management -> <a href="http://lists.puredata.info/listinfo/pd-list" rel="noreferrer" target="_blank">http://lists.puredata.info/listinfo/pd-list</a><br>
</font></span></blockquote></div><br></div>