Target not working???

David Burgun dburgun at dsl.pipex.com
Tue Mar 28 09:19:58 EST 2006


Hi Again Chipp!

I just thought of something else. Apart from using ISM as a message  
broadcast system, it can also be used as a central place to hold  
system wide (or inter-stack) data.

On 28 Mar 2006, at 11:01, Chipp Walters wrote:
> David,
>
> Also, I see where you're using custom props to hold non-permanent  
> data. While this is OK, I prefer to use library stack locals, as  
> these zero out when the app quits. That way you don't have to  
> explicitly reset them. I like customProps for data which may have  
> to be saved between sessions...just my 2 cents.

ISM has a concept of persistent data which remains across application  
launches (in a standalone) or across launches of the IDE.

As an example of this, take a Preferences Stack (a separate Prefs.rev  
file).

The user launches the standalone which takes them to the main  
application stack (call it AppMain.rev), this in turn allows them to  
select the preference stack. The user some system-wide preference  
(say the language is changed from English to Spanish). The preference  
stack sends a message ("LanguageChanged", "LanguageKindDefault",  
"Spanish") and all listening objects get the message and change  
themselves so that they now set their text to the new language).  
However since only AppMain.rev is "listening" it is the only stack to  
change.

The user now closes the Preferences Stack and Quits the App (or a  
developer quits the IDE).

The App is relaunched, the current stack  (AppMain.rev) is set to  
Spanish. The user now does something that calls up another stack like  
double clicking on a thumbnail of an image so as it see it in an  
ImageViewer/Editor (call this stack ImageEdit.rev). The language is  
still English in the (mageEdit.rev stack (or more accurately it's the  
language that was last chosen from the Preferences Stack when  
ImageEdit.rev was last open).

Normally you'd have to do something like call up the Preferences  
Stack (maybe making it invisible) so that it can re-send it's data)  
or have the Stack with the new data somehow send it to the new  
stack . However, in ISM if you make the data persistent, as soon as  
an Object(s) starts "listening" they get sent the data from the last  
time it was set, in this case "Spanish". The Preferences Stack  
doesn't have to be re-opened and there is no extra initialization  
code needed anywhere. The same path that handles a change also  
handles the initialization!

So, in order to do this, I need to store persistent data in a custom  
property. I intend hold this information in locals while the App is  
running and copy it into Custom Properties in the ISM stack when the  
last stack de-registers itself. That way I get the best of both worlds!

All the Best
Dave




More information about the use-livecode mailing list