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

system.verbs.builtins.dialog.loadFromFile

on loadFromFile (path) {
	<<loads the DLOG/DITL resources from a file
		<<first we try to use the path as a file path
			<<if that fails, we look in the Dialogs folder
		<<then we load in first DLOG/DITL whose id is 25000 or greater
			<<this ID was chosen at random, by convention all such files use this number
		<<we also load in all other resources whose ID is 25000 or greater
			<<this allows for custom controls, pictures, etc.
		<<then we assign the new DLOG an ID
			<<it's the ID of the DLOG we loaded from the original file
			<<if performance warrant, we'll come up with a way to allocate these
			<<so you don't have to load your resources every time your script runs
	
	if not file.exists (path) {
		path = Frontier.pathstring + "Dialogs:" + path;
		if not file.exists (path) {
			scriptError ("Can't locate the " + path + " dialog file.")}};
	
	local (rootpath = Frontier.getFilePath ());
	local (gotDLOG = false, gotDITL = false);
	local (dlogID = 25000);
	local (ixtype, ixrsrc);
	local (restype, id, name, x);
	
	for ixtype = 1 to rez.countResTypes (path) {
		rez.getNthResType (path, ixtype, @restype);
		for ixrsrc = 1 to rez.countResources (path, restype) {
			rez.getNthResInfo (path, restype, ixrsrc, @id, @name);
			if id >= 25000 {
				case restype {
					'DLOG' {
						if gotDLOG {
							continue};
						gotDLOG = true;
						dlogID = id};
					'DITL' {
						if gotDITL {
							continue};
						gotDITL = true}};
				if rez.getResource (path, restype, id, @x) {
					rez.putResource (rootpath, restype, id, @x)}}}};
	if not (gotDLOG and gotDITL) {
		scriptError ("Can't locate the dialog resources in " + path + ".")};
	
	return (dlogID)}



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.