broadcast messages

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderator: Klaus

Post Reply
mmiele
Posts: 55
Joined: Sun Jan 21, 2007 1:25 pm

broadcast messages

Post by mmiele » Sat Feb 21, 2009 12:06 pm

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/
Last edited by mmiele on Sun Feb 22, 2009 8:06 pm, edited 3 times in total.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Post by FourthWorld » Sun Feb 22, 2009 3:40 pm

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).
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply