Page 1 of 1

broadcast messages

Posted: Sat Feb 21, 2009 12:06 pm
by mmiele
It could be very useful to have a command to send a message to ALL objects in a card.
This way it would be possible to send messages as "initialize" or "update" and let each object process it in its own way.

It could also make easier using OOP polymorphism and encapsulation using the new Rev 3.5 Behaviours.

I'm actually doing it this way:

Code: Select all

on sendToAll pMsg -- send a message + n params to all the card controls
  -- pMsg format: message param1,param2,..
  local msgData,tHeader
  put pMsg into msgData
  if the paramCount > 1 then
        repeat with x=2 to the paramCount
            if x=2 then put " " into tHeader
            else put "," into tHeader
            put tHeader & param(x) after msgData
        end repeat
    end if
    repeat with i=1 to the number of controls in this card -- all the card controls
        try -- no error if the control doesn't exists
            send msgData to control i
        end try
    end repeat
end sendToAll
but a native command should be faster.

It could also be useful to have a "sendToGroup" message, to reach the objects of a group only.

You can download a Revolution example (a timer) on

http://www.mariomiele.it/downloads/

best regards,
Mario Miele
________________
e-voluzione
http://www.e-voluzione.it/

Posted: Sun Feb 22, 2009 3:40 pm
by FourthWorld
Have you seen v3.5's dispatch command?

It only partially covers what you're after, but is quite useful and benchmarks much faster than using "send" (and many times faster than using a series of "send" commands in a loop, how we used to craft our own dispatchers).