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

system.verbs.builtins.html.loadImageFile

on loadImageFile (f, adrtable, name=nil) {
	<<load a file of any type as a cell in the indicated table
		<<It can be a GIF, JPEG, Shockwave movie, whatever type you like.
		<<It's loaded into user.html.images. You can move it anywhere you like.
		<<The gifRef macro will understand if the 1st param is an address.
		<<12/30/98 Added name as an optional parameter for custom naming
	<<local (name = file.fileFromPath (f))
	if name == nil {
		name = file.fileFromPath (f);
		name = string.popSuffix (name)};
	if name contains " " { //only convert to innercase if there are spaces
		name = string.innerCaseName (name)};
	if not defined (adrtable^) {
		new (tabletype, adrtable)};
	local (type = file.type (f));
	local (flTextFile);
	bundle { //cross-platform way of determining if it's a text file
		case sys.os () {
			"MacOS" {
				flTextFile = type == 'TEXT'}}
		else {
			flTextFile = {"html", "htm", "txt"} contains string.lower (type)}};
	if flTextFile {
		wp.newTextObject (file.readWholeFile (f), @adrtable^.[name])}
	else {
		adrtable^.[name] = file.readWholeFile (f);
		setBinaryType (@adrtable^.[name], type)};
	return (@adrtable^.[name])};
bundle { <<test code
	loadimagefile ("D:\\Program Files\\OPML\\harrySmaller.gif", @workspace)}



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.