home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Programmierung / SOURCE.mdf / programm / msdos / pascal / pxl214a / pxlmenu.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-02-14  |  23.7 KB  |  700 lines

  1. {$R-}    {Range checking off}                                         {.CP14}
  2. {$B+}    {Boolean complete evaluation on}
  3. {$S+}    {Stack checking on}
  4. {$I+}    {I/O checking on}
  5. {$N-}    {No numeric coprocessor}
  6.  
  7. Unit PXLMENU;
  8.  
  9. Interface
  10.  
  11. Uses
  12.   Crt,
  13.   Dos,
  14.   PXLINIT;
  15.  
  16.  
  17. procedure Menu;
  18. procedure SetStyle;
  19. procedure LoadReserv;    {See comments in Implementation}
  20. procedure Initialize;
  21.  
  22. {===========================================================================}
  23.  
  24. Implementation
  25.  
  26. procedure Menu;                                                        {.CP7}
  27. var
  28.    Answer: char;
  29.    Ext,NameFirm,
  30.    Instructed,
  31.    NameInComLine,
  32.    GotFile:        boolean;
  33.  
  34.    procedure EnterName;                                               {.CP10}
  35.    begin
  36.       Blank(10,17);
  37.       CenterCRT('What File do you want to list?',10,Bright,0);
  38.       GotoXY(34,12); Filename := EditTrm(40);  {instead of read for neat Esc}
  39.       if (FileName[1]=#27) or (FileName[1]=#3) then
  40.          GetOutOfHere;
  41.       FixupFileName(FileName);
  42.       Command := #0;
  43.    end; {EnterName}
  44.  
  45.    procedure GetInstructions(Ans: CMD);                               {.CP18}
  46.    var
  47.       B:   byte;
  48.  
  49.    begin
  50.       Instructed := False;
  51.       Ans := InCapitals(Ans);
  52.       if (pos('F',Ans)<>0) and (Inst.Bt[FF]=12) then
  53.          FFeed := True else FFeed := False;
  54.       If (pos('V',Ans)<>0) then begin
  55.          Vanilla := True;
  56.          Plain := True;
  57.          XRef := False;
  58.          XRefOnly := False;
  59.          NumberLines := False;
  60.          Mrk := False;
  61.          Instructed := True;
  62.       end {if Vanilla}
  63.       else begin                                                      {.CP24}
  64.          Vanilla := False;
  65.          if pos('X',Ans)<>0 then XRef := True else XRef := False;
  66.          if pos('P',Ans)<>0 then begin
  67.             Plain := True;
  68.             Ans := 'P'  { P blanks L and M }
  69.          end {if P}
  70.          else {not plain}
  71.             Plain := False;
  72.          if pos('L',Ans)<>0
  73.             then NumberLines := True
  74.             else Numberlines := False;
  75.          if pos('M',Ans)<>0 then Mrk  := True else Mrk  := False;
  76.          if XRef and not (Plain or NumberLines or Mrk)
  77.             then XRefOnly := True
  78.             else XRefOnly := False;
  79.          if Plain or NumberLines or XRef or Mrk then
  80.             Instructed := True;
  81.          if InABatch and (not Instructed) then begin
  82.             Plain := True;
  83.             Instructed := True
  84.          end {if InABatch &c}
  85.       end; {else not Vanilla}
  86.    end; {GetInstructions}
  87.  
  88.    procedure ReadComLine;                                             {.CP21}
  89.    var
  90.       B:      byte;
  91.  
  92.       function OutputPeeled(C: CMD): string;
  93.       var
  94.          B,Len:   byte;
  95.          S:       Str40;
  96.       begin
  97.          B := pos('"',C);
  98.          S := '';
  99.          delete(C,B,1);         {remove 1st "}
  100.          while (C[B]<>'"') and (B<=length(C)) do begin
  101.             S := S + C[B];
  102.             delete(C,B,1);
  103.          end; {while not "}
  104.          if C[B]='"' then delete(C,B,1);
  105.          if S<>'' then
  106.             OutputDevice := S;
  107.          OutputPeeled := C
  108.       end; {OutputPeeled}
  109.  
  110.    begin  {ReadComLine}                                               {.CP19}
  111.       Command := '';
  112.       Instructed := False;
  113.       if ParamCount=0 then
  114.          FileName := ''
  115.       else begin
  116.          FileName := InCapitals(ParamStr(1));
  117.          if pos('"',FileName)<>0 then FileName := OutputPeeled(FileName);
  118.          if length(FileName)>0 then FixupFileName(FileName);
  119.          if ParamCount>1 then begin
  120.             for B := 2 to ParamCount do
  121.                Command := Command + InCapitals(ParamStr(B));
  122.             if pos('"',Command)<>0 then Command := OutputPeeled(Command);
  123.             if pos('BAT',Command)<>0 then InABatch := True;
  124.             if Escape then GetOutOfHere;
  125.             GetInstructions(Command);
  126.          end {else if got more params}
  127.       end {else got params}
  128.     end; {ReadComLine}
  129.  
  130.    function LongDate(Day,Month,Year: word): Str20;                     {.CP9}
  131.    const
  132.       Months: array[1..12] of Str5 = (
  133.               'Jan.','Feb.','March','April','May','June',
  134.               'July','Aug.','Sept.','Oct.','Nov.','Dec.');
  135.    begin {LongDate}
  136.       LongDate := Months[Month] + ' ' + StrgI(Day,1) + ', '
  137.                 + StrgI(Year,1);
  138.    end; {LongDate}
  139.  
  140.    function ShortDate(Day,Month,Year: word): Str9;                     {.CP5}
  141.    begin {ShortDate}
  142.       ShortDate := StrgI(Month,1) + '/' + StrgI(Day,1) + '/'
  143.                 + StrgI(Year-1900,1);
  144.    end; {ShortDate}
  145.  
  146.    function LongTime(Hour,Min,Sec: word): Str20;                      {.CP23}
  147.    var
  148.       Temp: Str20;
  149.    begin
  150.       if Sec>=30 then inc(Min);
  151.       if Min>59 then begin
  152.          inc(Hour);
  153.          Min := 0;
  154.       end; {if Min}
  155.       Temp := ' pm';
  156.       case hour of
  157.          0:      begin
  158.                     Hour := 12;
  159.                     Temp := ' am'
  160.                  end; {midnight-1 am}
  161.          13..24: Hour := Hour - 12;
  162.          else    Temp := ' am'
  163.       end; {case hour}
  164.       Temp := StrgI(Min,1) + Temp;
  165.       if Min<10
  166.          then LongTime := StrgI(Hour,1) + ':0' + Temp
  167.          else LongTime := StrgI(Hour,1) + ':' + Temp
  168.    end; {LongTime}
  169.  
  170.    function MilTime(Hour,Min,Sec: word): Str10;
  171.    begin
  172.       if Sec>29 then inc(Min);
  173.       if Min>59 then begin
  174.          inc(Hour);
  175.          Min := 0;
  176.       end; {if Min}
  177.       if Hour>23 then Hour := 0;
  178.       if Min<10
  179.          then MilTime := StrgI(Hour,1) + ':0' + StrgI(Min,1)
  180.          else MilTime := StrgI(Hour,1) + ':'  + StrgI(Min,1)
  181.    end; {MilTime}
  182.  
  183.    procedure MakeFileDateAndTime(FilName: string);
  184.    {Returns Date of file}
  185.    var
  186.       DTInt:          longint;
  187.       DT:             DateTime;
  188.       Fil:            file;
  189.       GotFile:        boolean;
  190.  
  191.    begin {MakeFileDateAndTime}
  192.       assign(Fil,FilName);
  193.       {$I-}
  194.       reset(Fil);
  195.       {$I+}
  196.       GetFTime(Fil,DTint);
  197.       close(Fil);
  198.       UnpackTime(DTint,DT);
  199.       FileDate := LongDate(DT.Day,DT.Month,DT.Year);
  200.       FileTime := LongTime(DT.Hour,DT.Min,DT.Sec);
  201.    end; {FileDateAndTime}
  202.  
  203.    function PresentDate: string;                                     {.CP7}
  204.    var
  205.       Mon,Day,Year,DayOWeek:word;
  206.    begin
  207.       GetDate(Year,Mon,Day,DayOWeek);
  208.       PresentDate := ShortDate(Day,Mon,Year);
  209.    end; {PresentDate}
  210.  
  211.    function PresentTime: string;                                     {.CP8}
  212.    var
  213.       Hr,Min,Sec,Sec100: word;
  214.    begin
  215.       GetTime(Hr,Min,Sec,Sec100);
  216.       if Sec100>49 then inc(Sec);
  217.       PresentTime := MilTime(Hr,Min,Sec);
  218.    end; {PresentTime}
  219.  
  220.    procedure GetFileAndDate;                                          {.CP17}
  221.    var
  222.       Local:  string;
  223.    begin
  224.       GotFile := FindFile(FileName);     {returns FALSE or openable filename}
  225.       if GotFile then begin
  226.          MakeFileDateandTime(FileName);
  227.          Local := FileName;
  228.          PathSign := '';
  229.          while (pos(':',Local)<>0) or (pos('\',Local)<>0) do begin
  230.             PathSign := PathSign + Local[1];
  231.             delete(Local,1,1)
  232.         end {while}
  233.      end {if GotFile}
  234.      else
  235.         if InABatch then GetOutOfHere;
  236.    end; {GetFileAndDate}
  237.  
  238.    procedure PostFile;                                                 {.CP7}
  239.    begin
  240.       CenterCRT(FileName + ', Created ' + FileTime + ', ' + FileDate,
  241.          7,Bright,Inside);
  242.       if not InABatch then
  243.          CenterCRT('Output will go to '+OutputDevice,BoxT+3,bright,inside);
  244.    end; {PostFile}
  245.  
  246.    function OptionsOK: boolean;                                        {.CP6}
  247.    const
  248.       Yes: set of char = [#13,'Y','y'];
  249.    var
  250.       Yep: char;
  251.       Row: byte;
  252.  
  253.       procedure CheckBill;                                             {.CP9}
  254.       var
  255.          Col:       byte;
  256.          S:         string;
  257.          ShortName: string;
  258.       begin
  259.          ShortName := Shortened(FileName);
  260.          Blank(9,17);
  261.          Row := 10;
  262.          if Vanilla then begin                                        {.CP15}
  263.             S := 'You want to print ' + ShortName + ' as plain text,';
  264.             Col := 40 - length(S) div 2;
  265.             WriteCRT(S,Row,Col,Bright);
  266.             inc(Row);
  267.                WriteCRT('with no inclusions or cross-ref, & nothing',Row,Col,bright);
  268.             inc(Row);
  269.             if FFeed  then begin
  270.                WriteCRT('numbered or counted, but',Row,Col,bright);
  271.                inc(Row)
  272.             end {if FFeed}
  273.             else
  274.                WriteCRT('marked, numbered or counted.',Row,Col,bright);
  275.             Col := 27;
  276.          end {if Vanilla}
  277.          else if XRefOnly then begin                                   {.CP8}
  278.             CenterCRT('You want to cross-reference '+ ShortName,Row,Bright,0);
  279.             inc(Row);
  280.             if FFeed then
  281.                CenterCRT('without printing the source code and',Row,Bright,0)
  282.             else
  283.                CenterCRT('without printing the source code',Row,Bright,0);
  284.          end {else if XRefOnly}
  285.          else begin                                                    {.CP9}
  286.             Col := 27;
  287.             WriteCRT('You want to list '+ShortName+' and',Row,24,Bright);
  288.             inc(Row);
  289.             if Mrk then
  290.                WriteCRT('M  Mark the key words',Row,Col,Bright)
  291.             else
  292.                WriteCRT('P  Leave the key words plain',Row,Col,Bright);
  293.             inc(Row);
  294.             if NumberLines then begin                                 {.CP21}
  295.                WriteCRT('L  Number the lines',Row,Col,Bright);
  296.                if Mrk then begin
  297.                   inc(Row);
  298.                   WriteCRT('   & count B/E pairs',Row,Col,Bright);
  299.                end{if Mrk}
  300.             end {if NumberLines}
  301.             else
  302.                WriteCRT('   NOT numbering the lines',Row,Col,Bright);
  303.             if XRef then begin
  304.                inc(Row);
  305.                WriteCRT('X  Cross-Reference the Identifiers  ',
  306.                           Row,Col,Bright);
  307.             end; {if XRef}
  308.          end; {else --not XRefOnly & not Vanilla}
  309.          if FFeed then begin
  310.             inc(Row);
  311.             WriteCRT('F  Feed out a blank page first      ',
  312.                       Row,Col,Bright);
  313.          end; {if FFeed}
  314.       end; {CheckBill}
  315.  
  316.    begin {OptionsOK}                                                  {.CP19}
  317.       if InABatch then
  318.          OptionsOK := True
  319.       else begin
  320.          CheckBill;
  321.          inc(Row);
  322.          if Row<17 then inc(Row);
  323.          WriteCRT('Is that correct? ',Row,24,Bright);
  324.          GotoXY(41,Row);
  325.          CursorOn;
  326.          Yep := KBin(Ext);
  327.          CursorOff;
  328.          if Yep in Triggers
  329.             then GetOutOfHere
  330.             else write(Yep);
  331.          Blank(16,Row);
  332.          OptionsOK := Yep in Yes
  333.       end {else not InABatch}
  334.    end; {OptionsOK}
  335.  
  336.    procedure Options;                                                 {.CP22}
  337.    var
  338.       Ans: CMD;
  339.       R:   byte;
  340.  
  341.       procedure OptionsBillboard;
  342.       begin
  343.          R := 10;
  344.          WriteCRT('Options: L for Line Numbering              '
  345.                   ,R,23,Bright);
  346.          inc(R);
  347.          WriteCRT('   M for Mark KeyWords               ',R,29,Bright);
  348.          inc(R);
  349.          WriteCRT('   X for X-Ref (Cross-reference)     ',R,29,Bright);
  350.          if Inst.Bt[FF]=12 then begin
  351.             inc(R);
  352.             WriteCRT('   F for Feed out a blank page       ',R,29,Bright)
  353.          end; {if Inst}
  354.          inc(R);
  355.          WriteCRT('   V for Vanilla (plain text)        ',R,29,Bright);
  356.          inc(R);
  357.       end; {OptionsBillboard}
  358.  
  359.    begin {Options}                                                    {.CP12}
  360.       Blank(9,16);
  361.       OptionsBillboard;
  362.       inc(R);
  363.       GotoXY(37,R); Ans := EditTrm(5);
  364.       if Ans='' then
  365.          Ans := 'P'
  366.       else if Ans[1] in triggers then
  367.          GetOutOfHere;
  368.       delay(200);
  369.       GetInstructions(Ans);
  370.    end; {Options}
  371.  
  372.    function NameOK: boolean;                                          {.CP20}
  373.    begin
  374.       Blank(7,16);
  375.       CenterCRT('Listing: ' + Filename + ', OK? ',11,Bright,0);
  376.       GotoXY(39,13);
  377.       CursorOn;
  378.       Answer := KBin(Ext);
  379.       CursorOff;
  380.       if Answer in Triggers then
  381.          GetOutOfHere
  382.       else if Answer=#13 then
  383.          Answer := 'Y';
  384.       write(Answer);
  385.       if Answer in [#13,'Y','y'] then begin
  386.          NameOK := True;
  387.          PostFile
  388.       end {if Y}
  389.       else
  390.          NameOK := False;
  391.    end; {NameOK}
  392.  
  393.    procedure NoSuchFile;                                               {.CP9}
  394.    begin
  395.       Beep;
  396.       Blank(8,12);
  397.       CenterCRT('Can''t find ' + Filename,7,Bright,0);
  398.       Bop;
  399.       if InABatch
  400.          then GetOutOfHere
  401.    end; {NoSuchFile}
  402.  
  403.    procedure GetID;                                                   {.CP16}
  404.    var
  405.       IDFile:      text;
  406.       FilNam:      string;
  407.    begin
  408.       FilNam := 'PXL.ID';
  409.       if FindFile(FilNam) then begin
  410.          assign(IDFile,FilNam);
  411.          reset(IDFile);
  412.          read(IDFile,UserID);
  413.          close(IDFile);
  414.       end {if no error}
  415.       else
  416.          UserID := ''
  417.    end; {GetID}
  418.  
  419.    procedure FirmUpName;                                              {.CP12}
  420.    begin
  421.       repeat
  422.          repeat
  423.             EnterName;
  424.             GetFileAndDate;              {Get creation date & set GotFile}
  425.             if not GotFile then NoSuchFile;            {Execute EnterName}
  426.          until GotFile;
  427.          NameFirm := NameOK=True;
  428.       until NameFirm;
  429.       PostFile
  430.    end; {FirmUpName}
  431.  
  432.    procedure FirmUpInstructions;                                       {.CP10}
  433.    var
  434.       Firm: boolean;
  435.    begin
  436.       Firm := False;
  437.       while not Firm do begin
  438.          Options;
  439.          if OptionsOK then Firm := True
  440.       end {while}
  441.    end; {FirmUpInstructions}
  442.  
  443.    procedure InitMenu;                                                {.CP14}
  444.    begin
  445.       Mrk := False;
  446.       NumberLines := False;
  447.       Enough := False;
  448.       XRef := False;
  449.       XRefOnly := False;
  450.       InABatch := False;
  451.       NameInComLine := False;
  452.       NameFirm := False;
  453.       GotFile := False;
  454.       GotPrnData := False
  455.    end; {InitMenu}
  456.  
  457. begin  {Menu}
  458.    InitMenu;                                                          {.CP15}
  459.    GetPrinterData;                           {Get printer specs from PXL.PRN}
  460.    ReadComLine;                      {Seek FileName, InABatch & Instructions}
  461.    if (FileName='') then
  462.       FirmUpName
  463.    else begin                      {Name in ComLine, maybe Instructions, too}
  464.       NameInComLine := True;
  465.       GetFileAndDate;                     {Exits on InABatch and Not GotFile}
  466.       if GotFile then
  467.          PostFile
  468.       else begin
  469.          NoSuchFile;
  470.          FirmUpName;
  471.       end; {else not GotFile}
  472.    end; {else FileName}
  473.    if Instructed then                   {instructed by ComLine}       {.CP19}
  474.       if not OptionsOK then begin
  475.          Instructed := False;
  476.          if not NameFirm then
  477.               if not NameOK then FirmUpName;
  478.          FirmUpInstructions
  479.       end; {if not OptionsOK}
  480.    if not Instructed then begin
  481.       Options;
  482.       if not OptionsOK then begin
  483.          if NameInComLine and not NameFirm then
  484.             if not NameOK then FirmUpName;
  485.          FirmUpInstructions;
  486.       end; {if not OptionsOK}
  487.       Instructed := True
  488.    end; {if not Instructed}
  489.    GetID;
  490.    PrintTime := PresentTime;
  491.    PrintDate := PresentDate
  492. end;  {Menu}
  493.  
  494. procedure SetStyle;                                                   {.CP20}
  495. var
  496.    I:              integer;
  497.    T:              TpFace;
  498. begin
  499.    if Inst.Bt[FF]<>12 then  {can't FF w/o #12 -dunno where on 1st page we are}
  500.       FFeed := False;
  501.    if Mrk then begin
  502.       Opening := Istring[MrkB];                           {Start underlining}
  503.       Closing := Istring[MrkE]                             {Stop underlining}
  504.    end {if Mrk}
  505.    else begin
  506.       Opening := '';
  507.       Closing := ''
  508.    end; {else --not Mrk}
  509.    QuitStrg := Istring[PostP];
  510. end; {SetStyle}
  511.  
  512. (*
  513. PROCEDURE TESTRESERV;                                            {.CP17}
  514. VAR C: CHAR;                {A debugging tool.  Not needed in actual run}
  515.     T: TEXT;
  516.     P: ResWPtrType;
  517. BEGIN
  518.    ASSIGN(T,'C:RESWDS');
  519.    REWRITE(T);
  520.    FOR C := 'A' TO 'Z' do begin
  521.       P := Rsv[C];
  522.       while P<>nil do begin
  523.          writeln(T,P^.R);
  524.          P := P^.Next;
  525.       end; {while not nil}
  526.    end; {for C}
  527.    close(T);
  528. END; {TESTRESERV}   *)
  529.  
  530. procedure LoadReserv;                                                 {.CP10}
  531.    {If constant DataFiles is set = True, this procedure will load the list  }
  532.    {of reserved words from file PXL.WDS (if it's on the path) and switches  }
  533.    {NRes (number of reserved words) and Turbo3 (which version of TP) will be}
  534.    {set automatically, below.  If you're adapting this to some other Pascal }
  535.    {than Turbo 3, 4, or 5, put your list of reserved words in file, PXL.WDS,}
  536.    {make sure Type ResWType is as long as your longest reserved word & Type }
  537.    {ResArr has room enough, and set DataFiles=True.  If you want to use the }
  538.    {internal data below, set DataFiles=False & set Turbo3 (in PXL.PAS, pro- }
  539.    {cedure Setup) true or false to fit the version you need.                }
  540. var
  541.    K: byte;
  542.    C: char;
  543.    Reserv: array[1..MaxResWords] of ResWType;
  544.  
  545. procedure ReadWds; {from PXL.WDS}                                     {.CP25}
  546.    var
  547.       Fil:            text;
  548.       FilNam:         string;
  549.       Res:            ResWType;
  550.       K,J:            integer;
  551.    begin
  552.       FilNam := 'PXL.WDS';
  553.       if FindFile(FilNam) then begin
  554.          assign(Fil,FilNam);
  555.          reset(Fil);
  556.          K := 0;
  557.          while not Eof(Fil) do begin
  558.             inc(K);
  559.             readln(Fil,Res);
  560.             for J := 1 to length(Res) do
  561.                Res[J] := UpCase(Res[J]);
  562.             Reserv[K] := Res
  563.          end; {while}
  564.          NRes := K;
  565.          close(Fil);
  566.          Turbo3 := NRes<45; {Note this overrides default setting in PXL.PAS }
  567.       end {if no error}     {User can adjust version by controlling the PATH}
  568.       else CantCont('PXL.WDS','Can''t find it on path.')
  569.    end; {ReadWds}
  570.  
  571.    procedure IntWds4; {This version for TP 4 & higher}
  572.    {This word list fits TP7, including the "Borland Pascal Directives" as  }
  573.    {well as the "Borland Pascal Reserved Words" --BPWO Language Guide, p 16}
  574.    begin
  575.       {if DataFiles = False, reserved words will be set thus:}
  576.       NRes := 65;
  577.       Reserv[1]  := 'ABSOLUTE';        Reserv[2]  := 'AND';
  578.       Reserv[3]  := 'ARRAY';           Reserv[4]  := 'ASM';
  579.       Reserv[5]  := 'ASSEMBLER';       Reserv[6]  := 'BEGIN';
  580.       Reserv[7]  := 'CASE';            Reserv[8]  := 'CONST';
  581.       Reserv[9]  := 'CONSTRUCTOR';     Reserv[10] := 'DESTRUCTOR';
  582.       Reserv[11] := 'DIV';             Reserv[12] := 'DO';
  583.       Reserv[13] := 'DOWNTO';          Reserv[14] := 'ELSE';
  584.       Reserv[15] := 'END';             Reserv[16] := 'EXPORT';
  585.       Reserv[17] := 'EXPORTS';         Reserv[18] := 'EXTERNAL';
  586.       Reserv[19] := 'FAR';             Reserv[20] := 'FILE';
  587.       Reserv[21] := 'FOR';             Reserv[22] := 'FORWARD';
  588.       Reserv[23] := 'FUNCTION';        Reserv[24] := 'GOTO';
  589.       Reserv[25] := 'IF';              Reserv[26] := 'IMPLEMENTATION';
  590.       Reserv[27] := 'IN';              Reserv[28] := 'INDEX';
  591.       Reserv[29] := 'INHERITED';       Reserv[30] := 'INLINE';
  592.       Reserv[31] := 'INTERFACE';       Reserv[32] := 'INTERRUPT';
  593.       Reserv[33] := 'LABEL';           Reserv[34] := 'LIBRARY';
  594.       Reserv[35] := 'MOD';             Reserv[36] := 'NAME';
  595.       Reserv[37] := 'NEAR';            Reserv[38] := 'NIL';
  596.       Reserv[39] := 'NOT';             Reserv[40] := 'OBJECT';
  597.       Reserv[41] := 'OF';              Reserv[42] := 'OR';
  598.       Reserv[43] := 'PACKED';          Reserv[44] := 'PRIVATE';
  599.       Reserv[45] := 'PROCEDURE';       Reserv[46] := 'PROGRAM';
  600.       Reserv[47] := 'PUBLIC';          Reserv[48] := 'RECORD';
  601.       Reserv[49] := 'REPEAT';          Reserv[50] := 'RESIDENT';
  602.       Reserv[51] := 'SET';             Reserv[52] := 'SHL';
  603.       Reserv[53] := 'SHR';             Reserv[54] := 'STRING';
  604.       Reserv[55] := 'THEN';            Reserv[56] := 'TO';
  605.       Reserv[57] := 'TYPE';            Reserv[58] := 'UNIT';
  606.       Reserv[59] := 'UNTIL';           Reserv[60] := 'USES';
  607.       Reserv[61] := 'VAR';             Reserv[62] := 'VIRTUAL';
  608.       Reserv[63] := 'WHILE';           Reserv[64] := 'WITH';
  609.       Reserv[65] := 'XOR';
  610.    end; {IntWds4}
  611.  
  612.    procedure IntWds3; {This version for Turbo 3}                      {.CP27}
  613.    begin
  614.       {if DataFiles = False, reserved words will be set thus:}
  615.       NRes := 44;
  616.       Reserv[1]  := 'ABSOLUTE';        Reserv[2]  := 'AND';
  617.       Reserv[3]  := 'ARRAY';           Reserv[4]  := 'BEGIN';
  618.       Reserv[5]  := 'CASE';            Reserv[6]  := 'CONST';
  619.       Reserv[7]  := 'DIV';             Reserv[8]  := 'DO';
  620.       Reserv[9]  := 'DOWNTO';          Reserv[10] := 'ELSE';
  621.       Reserv[11] := 'END';             Reserv[12] := 'EXTERNAL';
  622.       Reserv[13] := 'FILE';            Reserv[14] := 'FOR';
  623.       Reserv[15] := 'FORWARD';         Reserv[16] := 'FUNCTION';
  624.       Reserv[17] := 'GOTO';            Reserv[18] := 'IF';
  625.       Reserv[19] := 'IN';              Reserv[20] := 'INLINE';
  626.       Reserv[21] := 'LABEL';           Reserv[22] := 'MOD';
  627.       Reserv[23] := 'NIL';             Reserv[24] := 'NOT';
  628.       Reserv[25] := 'OF';              Reserv[26] := 'OR';
  629.       Reserv[27] := 'OVERLAY';         Reserv[28] := 'PACKED';
  630.       Reserv[29] := 'PROCEDURE';       Reserv[30] := 'PROGRAM';
  631.       Reserv[31] := 'RECORD';          Reserv[32] := 'REPEAT';
  632.       Reserv[33] := 'SET';             Reserv[34] := 'SHL';
  633.       Reserv[35] := 'SHR';             Reserv[36] := 'STRING';
  634.       Reserv[37] := 'THEN';            Reserv[38] := 'TO';
  635.       Reserv[39] := 'TYPE';            Reserv[40] := 'UNTIL';
  636.       Reserv[41] := 'VAR';             Reserv[42] := 'WHILE';
  637.       Reserv[43] := 'WITH';            Reserv[44] := 'XOR';
  638.    end; {IntWds3}
  639.  
  640.    procedure InsertResWord(Wd: ResWType);                             {.CP18}
  641.    var
  642.       P: ResWPtrType;
  643.    begin
  644.      if Rsv[Wd[1]]=nil then begin    {no reswords in this list yet}
  645.         new(Rsv[Wd[1]]);
  646.         Rsv[Wd[1]]^.Next := nil;
  647.         Rsv[Wd[1]]^.R := Wd;
  648.      end {if nil}
  649.      else begin
  650.         P := Rsv[Wd[1]];
  651.         while P^.Next<>nil do P := P^.Next;
  652.         new(P^.Next);
  653.         P := P^.Next;
  654.         P^.Next := nil;
  655.         P^.R := Wd;
  656.      end;                            {else list not empty}
  657.    end; {InsertResWord}
  658.  
  659. begin {LoadReserv}                                                    {.CP15}
  660.    if DataFiles then
  661.       ReadWds
  662.    else if Turbo3 then
  663.       IntWds3
  664.    else
  665.       IntWds4;
  666.    for C := 'A' to 'Z' do Rsv[C] := nil;
  667.    MaxResLen := 0;
  668.    for K := 1 to NRes do begin
  669.       InsertResWord(Reserv[K]);
  670.       if length(Reserv[K])>MaxResLen then MaxResLen := length(Reserv[K]);
  671.   end; {for each res wd}
  672. (* TESTRESERV;  {debuggery} *)
  673. end; {LoadReserv}
  674.  
  675. procedure Initialize;                                                {.CP23}
  676. var C: char;
  677. begin
  678.    CheckBreak := True;
  679.    FileName := '';
  680.    if Monitor=MDA then begin
  681.       ScrSeg := $B000;
  682.       Normalcolor := 15;
  683.       FrameColor := 7;
  684.       BackGround := 0;
  685.    end {if MDA}
  686.    else begin
  687.       ScrSeg := $B800;
  688.       NormalColor := ForegroundOf(NormalColor);      {in case of user dumbth}
  689.       FrameColor  := ForegroundOf(FrameColor);
  690.       Background  := Background and 7;
  691.    end; {else color board}
  692.    Bright := CombinedAttributeOf(NormalColor,Background);
  693.    Dim := CombinedAttributeOf(FrameColor,Background);
  694.    TextColor(NormalColor); TextBackground(Background);
  695.    BlnkLn[0] := char(Inside);
  696.    PXLRectangle;
  697. end; {Initialize}
  698.  
  699. End.
  700.