[PD] messages to messagebox

IOhannes zmoelnig zmoelnig at iem.kug.ac.at
Mon Dec 9 17:10:31 CET 2002


kristof lauwers wrote:
> Hi,
> 
> I'm trying to control PD from another app over UDP, connecting a 
> netreceive to a messagebox.
> Now i thought that, if i have a message with
> 
> ;
> $1 $2
> 
> (cfr. patch below)
> 
> i could send for example "testrecv 10", and a receive named testrecv 
> would receive the number.  i found out that for some reason you need to 
> send "foo testrecv 10" in stead..
> can anyone tell me why?  -  what's happening to the foo?

well if you read the console (which is generally a good thing to do)
you might notice something like
  "error: $1: symbol needed as message destination"

it is simple (and has nothing to do with netsend/netreceive)
imageine a sequence like "foo bar anything"
"foo" is then the header of this sequence, and "bar" & "anything" are 
the list-items.
normally, lists in pd look like "list a sequence 1 23 4"
note the header "list"
symbols look like "symbol mufti"
and so on

now, what does this mean to you ?
the message-box "|; $1 $2(" takes the first 2 elements of a sequence.
the header is not taken into account.
so "foo testreceive 10" is a sequence with header "foo" and elements 
"testreceive" & "10" (that's what happening with "foo": it is not 
counted as an element!)
"testreceive 10" is a sequence with header "testreceive" and one element 
"10" (that's why your send-construct fails: "10" is not a valid ID for 
send/receive, and btw, you don't supply a value to send

why is this so ?
don't know maybe historical reasons ?
anyhow, you can [route] things to wherever you like with the current 
implementation.
furthermore, it might turn out dangerous to allow sends to every 
receive, because anybody can send you something like "pd quit" (which 
might not be what you want)

so, what now ?
if you insist on your generic solution and only send pairs "symbol 
float", why not use

[netreceive 3000 1]
|
[unpack s 0]
|          |
[pack s 0  ]
|
[; $1 $2(


mfg.as.dr
IOhannes





More information about the Pd-list mailing list