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

system.verbs.builtins.html.commands.newPage

local (adr, adrNewPage, title, titleString);
local (maxLength = html.getPref ("maxFileNameLength"));

try {adr = table.getCursorAddress ()};

if not defined (adr^) { //Prompt the user for the name of a website.
	local (websiteName);
	if not (dialog.ask ("Create new page in which website?", @websiteName)) {
		return (false)};
	adr = @websites.[websiteName];
	if not defined (adr^) { //Does the website exist?
		dialog.alert ("Can't create a new page because the website \"" + websiteName + "\" doesn't exist.");
		return (false)}};

if typeOf (adr^) != tableType { //We're creating the new page in a table.
	adr = parentOf (adr^)};

if not dialog.ask ("Title of new page?", @title) { //Get the title from the user.
	return (false)};
adrNewPage = @adr^.[string.dropNonAlphas (string.innerCaseName (title))]; //Get the address for the new page.
titleString = "#title \"" + title + "\"\r"; //This directive will appear at the top of the new page.

if defined (adrNewPage^) { //The page already exists!
	edit (adrNewPage); //Open the already-existing page for editing.
	return (false)}; //Return false to say that a new page wasn't created.

wp.newTextObject (titleString, adrNewPage); //Create the new page.
edit (adrNewPage); //Open the new page for editing.
return (true) //A new page was created.



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.