on retitleArchivePage (adrPost, history) { if defined ( adrPost^.title ) == 0 { return}; scratchpad.thisPost = adrPost^; new (tableType, @match); regex.easyMatch ( "([0-9]+)/([0-9]+)/([0-9]+)" , adrPost^.when, @match); scratchpad.match = match; month = match.groupStrings[1]; day = match.groupStrings[2]; year = match.groupStrings[3]; d = month + "/" + day + "/" + year; scratchpad.d = d; // this is the date form in the when field of a post, e.g. 4/19/2002 scratchpad.archiveDate = year + "\\" + string.padWithZeros(month,2) + "\\" + string.padWithZeros(day,2); // canonical form scratchpad.archivePath = "c:\\radio\\www\\" + scratchpad.archiveDate + ".txt"; scratchpad.archiveFile = string ( file.readWholeFile(scratchpad.archivePath) ); new (listType, @l); for i = sizeof(weblogdata.posts) - history to sizeof(weblogdata.posts) { if ( regex.easyMatch ( d, weblogdata.posts[i].when ) ) { // gather posts on same date as this post l[0] = nameOf (weblogdata.posts[i])}}; «for adr in (@weblogdata.posts) «if ( regex.easyMatch ( d, adr^.when ) ) // gather posts on same date as this post «l[0] = nameOf (adr^) «else «continue scratchpad.l = l; scratchpad.mostRecent = l[sizeOf(l)]; // use most recent title for archive data if defined ( weblogdata.posts.[scratchpad.mostRecent].title ) == 0 { return}; scratchpad.title = "\"Jon Udell: " + weblogdata.posts.[scratchpad.mostRecent].title + "\""; if ( regex.easyMatch ( "#title " + regex.quoteRE(scratchpad.title) , scratchpad.archiveFile, @match ) == 0 ) { // missing/wrong if ( string.patternMatch ( "#title", scratchpad.archiveFile ) == 0 ) { // missing scratchpad.archiveFile = "#title " + scratchpad.title + "\r\n" + scratchpad.archiveFile; scratchpad.[adrPost^.title] = "action: added"} else { // wrong regex.subst ("#title [^\r\n]+\r\n", "#title " + scratchpad.title + "\r\n", @scratchpad.archiveFile);; scratchpad.[scratchpad.title] = "action: changed"}; file.writeWholeFile( scratchpad.archivePath, scratchpad.archiveFile ); scratchpad.[scratchpad.title] = scratchpad.[scratchpad.title] + ", file rewritten"}; «else «scratchpad.[adrPost^.title] = "action: none"}; local (history = 3); for i = sizeof(weblogdata.posts) - history to sizeof(weblogdata.posts) { msg( @weblogdata.posts[i] ); retitleArchivePage ( @weblogdata.posts[i] , history)}; «for adr in ( @weblogdata.posts) «retitleArchivePage ( adr ) msg ("archive titles updated at " + clock.now()); clock.sleepFor (60*60*1) « sleep