/****************************************************************** * * * Thinker Macro to process a captured BBS message file * * You will certainly have to customize this for your BBS * * * * This macro extracts messages as branches under the branch * * labeled "new". Subsequently you can sort the messages * * and define new branches by subject and move the messages * * around. Because the message number is the label, clicking * * on any thread # or reference # can jump to the referenced * * message * * * * This is for BBS-PC * * * * The resultant Thinker document looks like * * * * (new)New Messages * * (36157)Music: date time From: To: * * body of message * * (36158)JDR - #36139: date time From: To: * * body of message * * * * Use SORT BRANCH (First Chars) to sort the new messages * * by subject matter. Add new branches (at the same level as * * "new") for subjects of interest. Move the messages to these * * subject branches. When reading the messages follow the * * refereneces by double clicking on the reference numbers or * * follow the threads by clicking on the Reply numbers. * * * * * ******************************************************************/ trace off options results 'get label first new' /* test for the branch "new" */ if rc ~= 0 then return 100 'position save 1' /* save position of (new) branch */ headlvl='down' /* first header down from "new" */ 'input Enter message file name' /* get name of capture file */ if rc ~= 0 then return rc file=result if file='' then return 101 open('msg',file,'read') /* open the capture file */ if rc = 0 then return 106 /* now scan till we find the first message */ do forever /* skip till have first message header */ instr=readln('msg') if eof('msg') ~= 0 then do close('msg') return 102 end if ismsg(instr) ~= 0 then leave /* this is a message header, begin */ end /* now have first message */ do forever /* for each message till eof */ 'position restore 1' /* next header place */ number=getnumber(instr) /* get message number */ instr=readln('msg') /* read date line */ if eof('msg') ~= 0 then leave date=space(instr,1) /* the date info */ instr=readln('msg') /* read the subject line */ if eof('msg') ~= 0 then leave instr=substr(instr,7) /* skip Subj: */ instr=space(instr,1) /* squeeze spaces */ if substr(instr,1,1) = '#' then do /* rearrange subject */ i=index(instr,' ')-1 /* size of number */ snum=substr(instr,1,i) /* extract reference number */ subj=substr(instr,i+4) snum /* get the true subject */ end else subj=instr /* original subject */ head=subj||':' date /* subject plus date */ instr=readln('msg') /* read the FROM: line */ if eof('msg') ~= 0 then leave head=head space(instr,1) /* from */ instr=readln('msg') /* read the TO: line */ if eof('msg') ~= 0 then leave head=head space(instr,1) /* to */ 'add after' headlvl '('||number||')'||head /* add header */ if rc~= 0 then leave headlvl='same' /* subsequent headers at same level */ 'position save 1' /* save position for next header */ level='down' /* insert text as subordinate */ statement='' instr=readln('msg') /* start scan for text */ if eof('msg') ~= 0 then leave do forever /* process body of message */ if space(instr,0) = '' then do /* a blank line */ if statement ~= '' then do /* with some collected statement */ 'add after' level statement /* add statement to branch */ if rc ~= 0 then leave level='same' /* next statement same level */ statement='' end end else do /* concatenate lines of statement */ if (substr(instr,1,1) = ' ') & (statement ~= '') then statement=statement||'0a'x statement = statement instr end instr=readln('msg') /* read next line */ if (eof('msg') ~= 0) | (ismsg(instr) = 1) then do /* complete */ if statement ~= '' then do 'add after' level statement level='same' end leave end end if eof('msg') ~= 0 then leave end close('msg') return 'done' ismsg: procedure /* see if line is the beginning of a message */ parse arg str if substr(str,1,5) == ' Msg:' then return 1 else return 0 end getnumber: procedure /* isolate the message number */ parse arg str i=index(str,'#')+1 j=index(substr(str,i),' ') return substr(str,i,j-1) end skipbl: procedure /* skip blank lines */ do forever str=readln('msg') if eof('msg') then return '' if space(str,0) ~= '' then return str end end