cross-stack globals, also, file inclusion

Rob Cozens rcozens at pon.net
Thu Oct 23 13:13:23 EDT 2003


Jacque, et al:

* My primary constant list is, in effect, an index to lines of text 
in a file and/or variable.  It is there to facilitate handler 
readability, comprehension, and debugging.

Example:

	constant badInputWarning = 244

	answer sdbMessage(badInputWarning)

tells me a lot more than

	 answer sdbMessage(244).

It's kind of like referencing a field by name instead of id or ordinal.

* My secondary constant list is used to facilitate handler modification:

	constant simpleSearchIcon = 103405

	if the icon of button "Search Type" is simpleSearchIcon then ...

The idea here is, if I should later change the simple search icon to 
103450, I could make one change here and need modify nothing else. 
Of course, without global constants this doesn't hold true; but at 
least I only have to modify one constant declaration at the beginning 
of each script rather than searching for every instance of the icon 
number in every handler.

* An ancillary use of constants is to support multi-lingual, 
translatable applications:

	constant saveStackMenuItem = 133
	constant newStackMenuItem = 107
	constant copyStackMenuItem = 206
	constant unsupportedChoiceWarning = 2
	constant tryAgainPrompt = 202
	constant forgetItPrompt = 203


	on menuPick thePick
		put sdbMessage(saveStackMenuItem) into saveMe
		put sdbMessage(newStackMenuItem) into makeMe
		put sdbMessage(copyStackMenuItem) into copyMe
		put sdbMessage(forgetItPrompt) into quitNow
		switch thePick
		case saveMe
			...
			break
		case makeMe
			...
			break
		case copyMe
			...
			break
		default
			beep
			answer sdbMessage(unsupportedChoiceWarning) with \
				quitNow or sdbMessage(tryAgainPrompt)
			if it is quitNow then exit to top
			...
		end switch
	end menuPick
-- 
Rob Cozens
CCW, Serendipity Software Company
http://www.oenolog.net/who.htm

"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."

from "The Triple Foole" by John Donne (1572-1631)


More information about the use-livecode mailing list