Monday, November 08, 2010 at 12:06 AM.


on typeToString (type) {
	<<9/29/98; 7:21:56 PM by DW
		<<Give me a type and I'll return a string suitable for display
		<<I needed this for a web-based object database browser
		<<It may come in handy in other similar applications
		<<It's an inverted system.compiler.language.constants.
	local (adrcache = @system.temp.typeStringCache);
	if not defined (adrcache^) {
		new (tabletype, adrcache)};
	if defined (adrcache^.[type]) {
		return (adrcache^.[type])};
	local (adrconstantstable = @system.compiler.language.constants, i);
	for i = 1 to sizeof (adrconstantstable^) {
		if adrconstantstable^ [i] == type {
			adrcache^.[type] = nameOf (adrconstantstable^ [i]);
			return (adrcache^.[type])}};
	return ("unknownType")};

<<bundle //test code
	<<dialog.alert (typeToString (scriptType))

This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.