home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
CPM
/
TURBOPAS
/
RNF-PAS.LBR
/
RNF0.PQS
/
RNF0.PAS
Wrap
Pascal/Delphi Source File
|
2000-06-30
|
19KB
|
492 lines
(* --- rnf0 ---*)
PROCEDURE INI;
{ Initialization procedures }
var
j: integer;
PROCEDURE INISTDMACS;
const
EmptyMacroText =
' ';
type
alfa66 = packed array [ 1 .. 66] of char;
procedure InitMac(MacroName: alfa; MacText: alfa66);
var
TheMacroPtr: PMAC;
length, i: integer;
begin
new(TheMacroPtr);
with TheMacroPtr^ do
begin
ON := FALSE; NM := MacroName;
MT := HEADER; NP := 0;
MA := MACLSTP;
MacroBegin := FreeStgIndx;
if MacText = EmptyMacroText then
begin
Length := linlen;
(* allocate, but don't use the space *)
MacroEnd := MacroBegin - 1;
StgTable[MacroBegin] := ' ';
end
else
begin
Length := 66;
while ((Length > 1) and (MacText[Length] = ' ')) do
Length := Length - 1;
if MacText[Length] <> ' ' then
Length := Length + 1;
MacroEnd := MacroBegin + Length - 1;
for i := 1 to Length do
StgTable[MacroBegin + i - 1] := MacText[i];
end;
FreeStgIndx := MacroBegin + Length;
end;
MACLSTP := TheMacroPtr;
end;
BEGIN
MACLSTP := NIL;
InitMac('FRCPAGE ',
'.TOP .SAV .RESPAG .B 3 ..TTL ..NMP .BR ..STL .B 2 .RES .MID ');
FrcPgMacP := MACLSTP;
InitMac(' d-frcpage',
'.FRCPAGE ');
DefrFrcPgMacP := MACLSTP;
InitMac('.NMP ',
'$$PAGE=$$PAGE+1; .IF $$NMP .TAB $$RM .RT $$PAGE ');
InitMac('.TTL ', EmptyMacroText);
TTLMACP := MACLSTP;
InitMac('.STL ', EmptyMacroText);
STLMACP := MACLSTP;
InitMac('.CH ',
'.PAGE .FIG 12 .C ^CHAPTER $$CH=$$CH+1 $$HL=0; .B 2 .C ..CHT .B 3 ');
ChapterMacP := MACLSTP;
InitMac('.CHT ', EmptyMacroText);
CHTMACP := MACLSTP;
InitMac(' defer pp ',
'.PP ');
ParagMacP := MACLSTP;
InitMac(' defer cr ',
'.CR ');
CarRtnMacP := MACLSTP;
InitMac(' defer mid',
'.MID ');
MidMacP := MACLSTP;
END (*INISTDMACS*);
PROCEDURE INIRELS;
BEGIN
ARELOPR[EQ] := 'EQ '; ARELOPR[GT] := 'GT ';
ARELOPR[LT] := 'LT '; ARELOPR[NE] := 'NE ';
ARELOPR[GE] := 'GE '; ARELOPR[LE] := 'LE ';
END (*INIRELS*);
PROCEDURE INIVARS;
var
i: integer;
BEGIN
VID[VPAGE] := '$PAGE '; VTY[VPAGE] := VITEM;
VID[VCH] := '$CH '; VTY[VCH] := VITEM;
VID[VHL] := '$HL '; VTY[VHL] := VARRAY; VUP[VHL] := 5;
VID[VLIST] := '$LIST '; VTY[VLIST] := VARRAY; VUP[VLIST] := 5;
VID[VLM] := '$LM '; VTY[VLM] := VITEM;
VID[VRM] := '$RM '; VTY[VRM] := VITEM;
VID[VSP] := '$SP '; VTY[VSP] := VITEM;
VID[VNMP] := '$NMP '; VTY[VNMP] := VITEM;
VID[VOLNO] := '$OLNO '; VTY[VOLNO] := VITEM;
VID[VCR] := '$CR '; VTY[VCR] := VITEM;
VID[VANSI] := '$ANSI '; VTY[VANSI] := VITEM;
TV := NextVariable;
FOR i := 1 TO VARMAX DO VAL[i] := 0;
END (*INIVARS*);
PROCEDURE INICMDS;
PROCEDURE INIT1;
BEGIN
cmds[cinclude] := 'INCLUDE '; cmds[cbold] := 'BOLD ';
cmds[ccaseflag] := 'CASEFLAG ';
CMDS[CBLANK] := 'B '; CMDS[CFLAG] := 'FLAG ';
CMDS[CFLAGCAPS] := 'FLAGCAPS '; CMDS[CFLAGOVER] := 'FLAGOVER ';
CMDS[CFLAGSIG] := 'FLAGSIG '; CMDS[CLOWER] := 'LOWER ';
CMDS[CUPPER] := 'UPPER '; CMDS[CPERIOD] := 'PERIOD ';
CMDS[CBREAK] := 'BR '; CMDS[CCR] := 'CR ';
CMDS[CESCCHR] := 'ESC '; CMDS[CCENTER] := 'C ';
CMDS[CJUST] := 'J '; CMDS[CUL] := 'UL ';
CMDS[CLMAR] := 'LM '; CMDS[CRMAR] := 'RM ';
CMDS[CSUP] := 'SUP '; CMDS[CSTD] := 'STD ';
CMDS[CPS] := 'PAGESIZE '; CMDS[CSAV] := 'SAV ';
CMDS[CP] := 'P '; CMDS[CRES] := 'RES ';
CMDS[CPP] := 'PP '; CMDS[CSP] := 'SP ';
CMDS[CS] := 'S '; CMDS[CTP] := 'TP ';
CMDS[CNMP] := 'NMP '; CMDS[CPNO] := 'PNO ';
CMDS[CTITLE] := 'TITLE '; CMDS[CST] := 'ST ';
CMDS[CATITLE] := 'ATITLE '; CMDS[CLIST] := 'LIST ';
CMDS[CLE] := 'LE '; CMDS[CELIST] := 'ENDLIST ';
END;
PROCEDURE INIT2;
BEGIN
CMDS[CFIG] := 'FIG '; CMDS[CBAR] := 'BAR ';
CMDS[CBB] := 'BB '; CMDS[CEB] := 'EB ';
CMDS[CU] := 'U '; CMDS[CT] := 'T ';
CMDS[CTAB] := 'TAB '; CMDS[CTABS] := 'TABS ';
CMDS[CRT] := 'RT '; CMDS[CCH] := 'CH ';
CMDS[CAP] := 'AP '; CMDS[CI] := 'I ';
CMDS[CFILL] := 'F '; CMDS[CSIG] := 'SIG ';
CMDS[CPAGE] := 'PAGE '; CMDS[CFRCPAGE] := 'FRCPAGE ';
CMDS[CTOP] := 'TOP '; CMDS[CMID] := 'MID ';
CMDS[CBOT] := 'BOTTOM '; CMDS[CARRAY] := 'ARRAY ';
CMDS[CFMT] := 'FMT '; CMDS[CIF] := 'IF ';
CMDS[CASIS] := 'ASIS '; CMDS[CDOT] := 'DOT ';
CMDS[CREM] := 'REM '; CMDS[CUPP] := 'UP ';
CMDS[CUSB] := 'USB '; CMDS[CHL] := 'HL ';
CMDS[CRIGHT] := 'RIGHT '; CMDS[CLINES] := 'LINES ';
CMDS[CMACRO] := 'MACRO '; CMDS[CX] := 'X ';
CMDS[CVAR] := 'VAR '; CMDS[CINC] := 'INC ';
CMDS[CDEC] := 'DEC '; CMDS[CSAVPAG] := 'SAVPAG ';
CMDS[CRESPAG] := 'RESPAG '; CMDS[NOTCMD] := '----------';
BREAKSET := [CCENTER, CTITLE, CST, CI, CCH, CLE, CLIST, CELIST, CHL,
CCR, CPP, CPAGE, CFIG, CS, CTP, CBLANK, CASIS, CBREAK, CRES,
CRESPAG];
CRSET := BREAKSET - [CBREAK, CBLANK, CRES, CRESPAG];
END (* INIT2 *);
procedure IniPerfect;
{ Perfect hash function -- very fast keyword lookup }
begin
perfect[ 0] := NOTCMD;
perfect[ 1] := CP; perfect[ 2] := CPP;
perfect[ 3] := CNMP; perfect[ 4] := CPAGE;
perfect[ 5] := CJUST; perfect[ 6] := NOTCMD;
perfect[ 7] := CPERIOD; perfect[ 8] := CPS (* PAGESIZE *);
perfect[ 9] := CTP; perfect[10] := CTOP;
perfect[11] := CDOT; perfect[12] := CTITLE;
perfect[13] := CEB; perfect[14] := CELIST (* ENDLIST *);
perfect[15] := CT; perfect[16] := CBOLD;
perfect[17] := CX; perfect[18] := CSP;
perfect[19] := CSUP; perfect[20] := CSTD;
perfect[21] := CTAB; perfect[22] := CINCLUDE;
perfect[23] := CBLANK; perfect[24] := CBB;
perfect[25] := CST; perfect[26] := CUPP;
perfect[27] := CTABS; perfect[28] := CPNO;
perfect[29] := NOTCMD; perfect[30] := NOTCMD;
perfect[31] := CI; perfect[32] := CRT;
perfect[33] := CS; perfect[34] := CLE;
perfect[35] := CRIGHT; perfect[36] := CBREAK;
perfect[37] := CBAR; perfect[38] := CUSB;
perfect[39] := CESCCHR; perfect[40] := CDEC;
perfect[41] := NOTCMD; perfect[42] := CRES;
perfect[43] := CLIST; perfect[44] := NOTCMD;
perfect[45] := CFRCPAGE; perfect[46] := NOTCMD;
perfect[47] := CAP; perfect[48] := CFMT;
perfect[49] := CU; perfect[50] := CMID;
perfect[51] := CATITLE; perfect[52] := CUPPER;
perfect[53] := CLINES; perfect[54] := CINC;
perfect[55] := CIF; perfect[56] := CSIG;
perfect[57] := CSAV; perfect[58] := CUL;
perfect[59] := CSAVPAG; perfect[60] := CLOWER;
perfect[61] := CCR; perfect[62] := CFLAGCAPS;
perfect[63] := CBOT (* BOTTOM *); perfect[64] := CVAR;
perfect[65] := CASIS; perfect[66] := CRESPAG;
perfect[67] := CARRAY; perfect[68] := NOTCMD;
perfect[69] := CFLAGOVER; perfect[70] := CHL;
perfect[71] := CRMAR; perfect[72] := CREM;
perfect[73] := CCENTER; perfect[74] := CCH;
perfect[75] := NOTCMD; perfect[76] := CMACRO;
perfect[77] := CFILL; perfect[78] := CFIG;
perfect[79] := CFLAG; perfect[80] := CLMAR;
perfect[81] := CCASEFLAG; perfect[82] := CFLAGSIG;
end;
procedure IniLetPerfect;
begin
LetPerfect['A'] := 45; LetPerfect['B'] := 11;
LetPerfect['C'] := 36; LetPerfect['D'] := 1;
LetPerfect['E'] := 0; LetPerfect['F'] := 38;
LetPerfect['G'] := 37; LetPerfect['H'] := 36;
LetPerfect['I'] := 15; LetPerfect['J'] := 2;
LetPerfect['K'] := 0; LetPerfect['L'] := 32;
LetPerfect['M'] := 46; LetPerfect['N'] := 0;
LetPerfect['O'] := 25; LetPerfect['P'] := 0;
LetPerfect['Q'] := 0; LetPerfect['R'] := 23;
LetPerfect['S'] := 16; LetPerfect['T'] := 7;
LetPerfect['U'] := 24; LetPerfect['V'] := 38;
LetPerfect['W'] := 0; LetPerfect['X'] := 8;
LetPerfect['Y'] := 17; LetPerfect['Z'] := 0;
end;
procedure initchars;
var
achar: char;
begin
for achar := chr(0) to chr(127) do { 7-bit ASCII characters }
begin
CharCategory[achar] := OtherChar;
(* default -- no case conversion *)
MakeUpper[achar] := achar;
MakeLower[achar] := achar;
if (achar >= 'a') and (achar <= 'z') then
CharCategory[achar] := lcLetter
else
if (achar >= 'A') and (achar <= 'Z') then
CharCategory[achar] := ucLetter;
end;
for achar := chr(128) to chr(255) do { 8-bit ASCII characters }
begin
CharCategory[achar] := MiscChar; { these pass through and print }
(* no case conversion *)
MakeUpper[achar] := achar;
MakeLower[achar] := achar;
{ comment-out either DEC or IBM-PC }
(* DEC VT220, Rainbow character set *)
{ 128 .. 159 are control chars, and are not printed }
{ 192 .. 253 are foreign characters, upper or lower case }
if (achar < chr(160)) then
CharCategory[achar] := OtherChar
else
if (achar >= chr(192)) and (achar <= chr(253)) then
CharCategory[achar] := lcLetter;
(* IBM-PC 8-bit characters, all are printable *)
{ 128 .. 167 are foreign characters (more or less) }
{
if (achar < chr(168)) then
CharCategory[achar] := lcLetter;
}
end;
CharCategory['^'] := UpArrow;
CharCategory['<'] := LeftAngle;
CharCategory['.'] := EndSentence;
CharCategory['?'] := EndSentence;
CharCategory['!'] := EndSentence;
CharCategory['_'] := UnderScore;
CharCategory['#'] := NumberSign;
(* ASCII dependent *)
{} CharCategory[chr(92)] := BackSlash;
CharCategory['{'] := MiscChar;
CharCategory['}'] := MiscChar;
{} CharCategory[chr(126)] := MiscChar (* tilda *);
{} CharCategory[chr(96)] := MiscChar (* grave *);
{} CharCategory[chr(124)] := MiscChar (* vertical bar *);
{} for achar := ' ' to ']' do
if CharCategory[achar] = OtherChar then
CharCategory[achar] := ArithChar;
RomanChars := 'M CMD CDC XCL XLX IXV IVI ';
RomanValue[ 1] := 1000;
RomanValue[ 2] := 900;
RomanValue[ 3] := 500;
RomanValue[ 4] := 400;
RomanValue[ 5] := 100;
RomanValue[ 6] := 90;
RomanValue[ 7] := 50;
RomanValue[ 8] := 40;
RomanValue[ 9] := 10;
RomanValue[10] := 9;
RomanValue[11] := 5;
RomanValue[12] := 4;
RomanValue[13] := 1;
end;
BEGIN (* INICMDS *)
INIT1;
INIT2;
IniPerfect;
IniLetPerfect;
initchars;
END (*INICMDS*);
PROCEDURE INIFILES;
VAR
OUTNAME: string80;
ans: char;
badname, FromOS : boolean;
function CommandLineFile : boolean;
{ If nothing given on command line, write message and ruturn false. }
{ Else set InputName and outname }
{ Highly OS- and compiler-dependent; ParamCount, ParamStr Turbo Pascal }
{ For Turbo v 1 or 2, modify this routine to just return false. }
BEGIN
if ParamCount < 1 then { ParamCount requires Turbo v 3 }
begin
CommandLineFile := false;
writeln(' Give input file on RNF command line for listing to ',
'printer and auto eject.');
end
else
begin
CommandLineFile := true;
InputName := ParamStr(1);
outname := 'lst:'; { MS-DOS or CP/M printer }
end;
END { CommandLineFile };
BEGIN
FromOS := CommandLineFile;
repeat
badname := false;
if not FromOS then
begin
WRITE(' INPUT FILE >');
readln(InputName);
end;
{}{VMS,Turbo} if length(InputName) = 0 then halt;
{ VMS allows "length" on a PAOC, Turbo only on their string type }
if not fileexists(InputName) then
{VMS} {begin
InputName := concat(InputName, '.text');
if not fileexists(InputName) then
begin
badname := true;
writeln(' not present')
end
end;}
begin
badname := true; FromOS := false;
writeln(InputName, ' not present')
end
until not badname;
if not FromOS then
begin
WRITE(' LISTING FILE >');
readln(outname);
end;
{}{VMS,Turbo,Prospero} if length(outname) = 0 then halt;
{}{VMS} { open(File_Variable:=InFile,File_Name:=Inputname, History:= old); }
{}{Turbo,Prospero} assign(INFILE,InputName);
RESET(INFILE);
{}{VMS} { open(File_Variable:=OutFile,File_Name:=OutName,History := new, }
{}{VMS} { Record_Length:= 322); }
{}{Turbo,Prospero} assign(OUTFILE,outname);
{}{VMS} { REWRITE(OUTFILE, error := continue); }
{}{Turbo,Prospero} REWRITE(OUTFILE);
if FromOS
then HandFeed := false
else
repeat
write(' Hand feed paper or Auto page eject ? [H/A] >');
read(ans);
writeln;
HandFeed := (ans = 'H') or (ans = 'h');
until ans in ['H','A','h','a'];
END (* INIFILES *);
BEGIN (*INI*)
VarName := AlfaBlanks;
DangerPoint := maxint div 10;
INIFILES; INIRELS;
InitialPageEject := false; { true for PAGE( ) before first page printed }
USB := TRUE; doinclfl := false;
UNDL := FALSE; bold := false; asis := false; XTEND := FALSE;
ERRORCOUNT := 0; ILNO := 0; EOFINPUT := FALSE;
FREEMACP := NIL; FLAGOVER := TRUE;
FLAGSIG := TRUE; T := FALSE; RT := FALSE; DOT := FALSE;
PUSHED := FALSE; PMAR := 0; AP := FALSE; PARA := FALSE;
RIGHT := TRUE; RT := FALSE;
OVETXT := 58; OETXT := 58; OEPAG := 66; ENP := 0;
SUP := FALSE; YES := TRUE; ENP := 0; PARSPACE := 1;
PARTEST := 3; DEFRB := 0; PREL := TRUE; FIRSTCH := TRUE;
FORCE := FALSE; ATITLE := FALSE; FIGP := 0; BAR := FALSE;
BB := FALSE; CLRTAB;
ITEMSET := ['$', '0' .. '9', '+', '-', '#', '.'];
TERMSET := ITEMSET + ['('];
StgMarker := StgTblSize;
TopOfStack := 0;
with StgStack[0] do
begin
ActiveMacro := nil;
StgBegin := 1;
StgEnd := linlen;
FreeStgIndx := StgEnd + 1;
StgPosition := 1;
end;
for j := 1 to FreeStgIndx do
StgTable[j] := ' ';
{} {fillchar(StgTable, StgTblSize, ' ');}
for j:=1 to StgTblSize do StgTable[j] := ' ';
INISTDMACS; INICMDS; SETSTD;
INIVARS;
VAL[VNMP] := 1; VAL[VRM] := 72; VAL[VSP] := 1;
{} val[vcr] := {128+} 13; { This character returns carriage to left edge }
VAL[VLM] := 1;
for j := 0 to LinLen do
EmptyFlags[j] := false;
CLRLINE;
with otl do
begin
HasBoldPrinting := false; HasOverPrinting := false;
HasUnderScore := false;
USflag := EmptyFlags;
BoldFlag := EmptyFlags;
FOR j := 1 TO LINLEN DO
LIN[j] := ' ';
end;
SYL := OTL; TMPL := OTL; PAGSAV := OTL;
ADDSYL := OTL;
PQEND := FALSE; OVBTXT := 0;
WITH JUST DO
FOR j := 1 TO LINLEN DO POS[j] := 0;
JUST.NDX := 0;
RIGHTSPACE := 0;
FOR j := 1 TO FIGMAX DO FIGN[j] := 0; HOLDBB := FALSE;
LASTCUP := 0; LASTLEN := 0; LASTSLEN := 0;
PAGOTL := FALSE; EXPRERR := FALSE;
SHOWEXPR := TRUE; XTRABL := PQEND;
VAL[VOLNO] := 10000; SAVENV(PAGENV); PushText(MidMacP);
END (*INI*);