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

system.verbs.builtins.table.surePath

on surePath (s) {
	if nameOf (s^) != "" { <<it's already a good path; don't need to do anything
		return (0)};
	
	local (field, len, adr = @root, ctnewtables = 0);
	
	<<while true // old code
		<<if s beginswith '['
			<<len = string.patternMatch ("].", s)
			<<if len == 0 <<matching bracket is at end of string
				<<break
			<<field = string.mid (s, 1,  len)
		<<else
			<<field = string.nthField (s, '.', 1)
			<<if field == s <<last dotted field in string
				<<break
		<<s = string.delete (s, 1, string.length (field)+1)
		<<adr = adr + "." + field
		<<if not defined (adr^)
			<<new (tableType, adr)
			<<ctnewtables++
	try {
		local (ixstart, namelist = string.parseAddress (s));
		adr = @[namelist [1]];
		if defined (adr^) && typeof (adr^) == tabletype {
			ixstart = 2}
		else {
			adr = @root;
			ixstart = 1};
		
		local (i); //PBS 6/3/99: this local declaration was missing
		for i = ixstart to sizeof (namelist) - 1 {
			adr = @adr^.[namelist [i]];
			if not defined (adr^) {
				new (tableType, adr);
				ctnewtables++}}};
	
	return (ctnewtables)}



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.