(* ENDNOTE Re-created: Oct. 26, 1987 David Weinberger Revised by Robert Arnold, Nov. 5, 1987 *) CONST ClrToEnd=^W; Beep=^G; SuperChar1=^T; (* change these values for your wordprocessor *) SuperChar2=^T; (* these are for Wordstar *) PageBreak='.pa'; (* page break to note page/s *) NotesTitle=^S'Notes'^S; (* Underlined "Notes" title *) TitleField=32; (* centers note title *) NoteIndent=' '; (* indent notes 5 spaces *) VAR fv,fvfmt,fvftn: text; footnotefile,formatfile,filename:string[14]; extraline,filechr: char; howmany,footnumb,nchar:integer; append,backslash, InEndNote: boolean; delimiter: set of char; PROCEDURE signon; begin clrscr; gotoxy (1,2); write('\ENDNOTE\');write(' version 1.2');writeln; writeln('(c) copyright D. Weinberger, 1985,1987'); writeln('Revised by Bob Arnold, 1987'); writeln;writeln; DELAY(500); end; PROCEDURE GetFileName; var ok : boolean; x : integer; begin ok:=true; repeat write('Enter name of file to use: '); readln(filename); (* uppercase it *) for x:=1 to length(filename) do filename[x]:=upcase(filename[x]); assign(fv,filename); {$i-} reset(fv); {$I+} ok:=(IOresult=0); if not ok then writeln('Cannot find: ', filename); until ok; gotoxy(1,5); write(ClrToEnd); writeln;writeln; write('Working file: '); write(filename); end; PROCEDURE opennew; begin if pos('.',filename)>0 then delete(filename,pos('.',filename),10); formatfile:=filename+'.FMT'; footnotefile:=filename+'.FTN'; assign(fvfmt,formatfile); rewrite(fvfmt); assign(fvftn,footnotefile); rewrite(fvftn); end; PROCEDURE MakeScreen; VAR AppendResponse : char; begin Append:=false; writeln;writeln;writeln;write('Enter starting note number: '); readln(footnumb); write('Insert line between notes? '); readln(extraline); write('Append notes to text file? '); readln(AppendResponse); if (AppendResponse = 'y') or (AppendResponse = 'Y') then Append:=true; gotoxy(1,15);write(clrToEnd,'Number of notes found: ', howmany); end; PROCEDURE WriteSuperScript; begin footnumb:=succ(footnumb); write(fvfmt,Superchar1,footnumb,superchar2); write(fvftn,NoteIndent,Superchar1,footnumb,superchar2); end; (*========================== MAIN ============================*) begin InEndNote:=false;footnumb:=1;howmany:=0; (* This sets the footnote delimiter to backslash. If you want something else, it can be changed here. *) delimiter:=[chr(92),chr(220)]; SIGNON; GETFILENAME; OPENNEW; MAKESCREEN; footnumb:=pred(footnumb); while not eof(fv) do begin read(fv,filechr); if filechr in delimiter then backslash:=true else backslash:=false; if backslash then inendnote:=not inendnote; if backslash then begin if inendnote then begin howmany:=succ(howmany); gotoxy(24,15);write(howmany); WRITESUPERSCRIPT; end; if not inendnote then begin writeln(fvftn); (* Put in a CR/LF *) if (extraline = 'y') or (extraline = 'Y') then writeln(fvftn); {Put in an extra line between notes} end; end; if not backslash then begin if inendnote then write(fvftn,filechr) else write(fvfmt,filechr); end; end; { ====================of main loop============================= } (* ===============append endnotes to format file=================== *) if not inendnote then if Append = true then begin writeln(fvfmt); writeln(fvfmt,PageBreak); writeln(fvfmt,NotesTitle:TitleField); writeln(fvfmt); if (extraline = 'y') or (extraline = 'Y') then writeln(fvfmt); { add additional line between title & notes } RESET(FVFTN); while not EOF(fvftn) do begin READ(FVFTN,FILECHR); WRITE(FVFMT,FILECHR); end; writeln(fvfmt); end; (* =========================end of append section======================= *) close(fv);close(fvfmt);close(fvftn); writeln;writeln;writeln; if Append = true then begin if howmany>0 then begin ERASE(fvftn); write(beep,'Formatted file written to: '); write(formatfile);writeln; write('Note range: '); write(footnumb-howmany+1,'-',footnumb); writeln;writeln; end else if howmany=0 then begin writeln(beep,'*** ERROR: No notes found.'); erase(fvfmt);erase(fvftn); writeln;writeln;writeln; end; end; if Append = false then begin if howmany>0 then begin write('Text file: '); write(formatfile);writeln; write(beep,'Note file: '); write(footnotefile);writeln; write('Note range: '); write(footnumb-howmany+1,'-',footnumb); writeln;writeln; end else if howmany=0 then begin writeln(beep,'*** ERROR: No notes found.'); erase(fvfmt);erase(fvftn); writeln; end; end; if inendnote then begin DELAY(500); writeln(beep,'*** ERROR: Unmatched delimiter in source file.'); writeln;EXIT; end; end.