[EMAIL PROTECTED] wrote:
> malte wrote:
> > Im also making a multi-connection app, and had the same problems, however,
> I don't get things to work with dispatch either..
> > perhaps Im not using it properly.. syntax, anyone? :)
> >
> > right now I go like
> > port: dispatch [port1 port2]
> >
> > wrong?
>
> Yes. That's wrong. Have a look at the source for 'dispatch:
>
> >> source dispatch
> dispatch: func [
> {Wait for a block of ports. As events happen, dispatch port handler
> blocks.}
> port-block [block!] {Block of port handler pairs (port can be timeout
> too).}
> /local ports awake timeblk result
> ][
> ports: copy []
> foreach [port job] port-block: reduce port-block [
> if any [number? port time? port] [if none? timeblk [timeblk: :job]]
> append ports port
> ]
> forever [
> either awake: wait/all ports [
> if foreach item awake [
> set/any 'result do select port-block item item
> if all [value? 'result 'break = :result] [break/return true]
> ] [break]
> ] [do :timeblk]
> ]
> ]
>
> Note the 'foreach:
> foreach [port job] port-block
ah, it's interesting - do you really prefer this aproach? (nested blocks) I
remember Carl ones discussed he prefers one aproach, but I don't remember the
result ...
I would probably prefer having separate block with handlers parallel to
port-block ...
-pekr-
>
> There's a job after each port value. Try:
> dispatch [port1 Port1Handler port2 Port2Handler]
> and have:
> Port1Handler: func [...
> etc.
>
> I hope that helps!
>
> Andrew Martin
> ICQ: 26227169
> http://members.ncbi.com/AndrewMartin/
> http://members.xoom.com/AndrewMartin/
> -><-