Where oh where did my globals go?
November 18, 1998
by Alex Zavatone
ShowGlobals is one of the first commands that gets discovered when you're working on getting started with Director. And not too far after, you learn that showGlobals -- along with some other commands -- only dumps its output to the message window. You can't ask Director to dump the values into a field or other location. This can be a real pain when you can't remember all your global names and want to get some values or create a window that monitors your globals for you.
Back in the Director 4 days, I got sick of this limitation and thought that if you could read through all the scripts you could find and store a list of global values and then use the "do" command to get the value of the fetched globals. From that, I built an authoring tool MIAW to monitor all your global variables for you. Something that often comes in handy for me.
Recently, there has been renewed discussion on the Direct-L about "how to get my globals to display outside the message window". With renewed interest, I dug up my old code and sent it off to Chris Allert who spiffed it up and added multi castlib support. The resulting chunk of code consists of 4 handlers that you can call to get your list of globals and display their values.
Note: this code is meant to be run from either the stage or a miaw.
Handlers | Function |
GetGlobalList() | returns a list of all globals that are declared inside a handler |
ParseGlobalLineList globalLineList | parses the globals out of the text string returned (private) |
DisplayGlobalValues theGlobalList | displays the globals and their values |
GhGlobalValues() | returns a property list of the globals and their values |
To get a list of globals, simply issue the following line:
put GetGlobalList()
or
set myGlobalList = GetGlobalList()
to display the values of all globals,
put DisplayGlobalValues( GetGlobalList( ))
or:
set myGlobalList =DisplayGlobalValues( GetGlobalList( ))
to return a property list of all the globals and their values,
set myGlobalList = GhGlobalValues()
And there you have it!
Possible modifications to this code are to make it non repeat based so that other actions can happen while it is finding all the globals and global info.
Many thanks to Chris Allert who got the thread going again and brought the code up from the mid 90's to the late 90's.
Download the castlib in Macor PC format
Copyright 1997-2024, Director Online. Article content copyright by respective authors.