1. html page creator, part deux
- Posted by Hawke <mdeland at NWINFO.NET> Jun 28, 1998
- 962 views
--------------A5DA9599849A1ECD95B08809 okay, updated search/replace (newfile attached) in creator.ex and made a version (changed extension basically) for exw that runs from a shortcut. benefit? i got long file names working in a (for all intentent purposes) DOS program. include some_beaming_smiles.:). while grinning_wide do Mosh_Adamantly() --then end --the festivities for a while heh, woulda nevah thought that'd work...go figure... onwards...now to get the autoURLlinking system going... hrmmmmm *scurries away* --------------A5DA9599849A1ECD95B08809 Content-Disposition: inline; filename="creator.exw" constant SCREEN = 1 constant TRUE = 1 sequence links, topics, template, newfile, newfilename links = {} topics = {} template = {} newfile = {} newfilename = {} function ReadFile(sequence filename) --reads a file, returns a sequence sequence data integer fileNum object line data = {} fileNum = open(filename, "r") if fileNum = -1 then printf(SCREEN, "readfile cannot open %s\n", filename) abort(1) else while TRUE do line = gets(fileNum) if atom(line) then -- end of file close(fileNum) return data end if data = data & {line} end while end if end function function SearchReplace( sequence lookinhere, sequence lookfor, sequence replace) --replaces the word <lookfor> within <lookinhere> with <replace> --does so by finding where <lookfor> begins, slicing --everything up to that point, and where <lookfor> --ends, slicing everything after that, then pasteing --together the beginning, replacement, and ending integer location sequence first, last, temp replace = replace[1..length(replace)-1] --squish CR for index = 1 to length(lookinhere) do location = match(lookfor, lookinhere[index]) if location != 0 then first = {} last = {} temp = {} --not needed, easier 2 read temp = temp & lookinhere[index] --back up to the preceding space, slice beginning first = first & temp[1..location-1] --goto end of <lookfor>, slice ending last = last & temp[location+length(lookfor)..length(temp)] --paste it back together with replacement in middle lookinhere[index] = first & replace & last end if end for return lookinhere end function procedure SaveFile(sequence filename, sequence data) --saves the newly created page replete with --titles and such based on template to filename --which is generated based on <topic>.htm integer fileNum fileNum = open(filename, "w") if fileNum = -1 then puts(SCREEN,"error in savefile, cant open\n") abort(1) end if for index = 1 to length(data) do puts(fileNum,data[index]) end for close(fileNum) end procedure --links = ReadFile("links.txt") --getting links to work is another day's project topics = ReadFile("topics.txt") template = ReadFile("template.html") for index = 1 to length(topics) do newfile = SearchReplace(template,"template",topics[index]) newfilename = {} newfilename = newfilename & topics[index] newfilename = newfilename[1..length(newfilename)-1] --squish CR newfilename = newfilename & ".html" SaveFile(newfilename, newfile) end for --------------A5DA9599849A1ECD95B08809--