Advice on Messaging System
dburgun at dsl.pipex.com
Tue Dec 13 07:26:32 CST 2005
I have a problem that I have solved, but wondering if anyone on this
list could think of a better/faster way of doing the same thing.
I have a number of Stacks then can be opened or closed under user
control, each stack can generate an "Event" or "Message". One such
message is "PrefsLanguage" which is generated when the user selects a
new new language in the Preferences Window. The messange is sent to
all objects that are "Listening" for the message.
The code looks like this.
In the Script for whichever controls need to know that language has
changed (in any stack), this handler is called from the preOpenStack
get ListenForMessage("PrefsLanguage","ControlMessageHandler",the long
name of me)
-- This Handler gets called when a "PrefsLanguage" Message is Generated
- Change the text of this control to the language contained in
The above code is placed in all objects that want to receive the message.
In the Prefs Stack, in the control that switches languages:
The message gets send to all Objects that are lintening for the
"PrefsLanguage" message (including objects on the same stack).
At present I represent this using a number of arrays which are
dynamically created (e.g. their names are built dynamically), but it
seems quite slow.
Does anyone know of a better way to do this? Any ideas or suggestions
Thanks a lot
All the Best
More information about the use-livecode