home *** CD-ROM | disk | FTP | other *** search
/ Hot Shareware 32 / hot34.iso / ficheros / DTOOL / INTER57F.ZIP / INT2WHLP.ZIP / INT2WHLP.PAS < prev    next >
Pascal/Delphi Source File  |  1998-03-01  |  49KB  |  1,334 lines

  1. (*
  2.   Interrupt List -> WinHelp converter (c) 1994 by Christian Müller-Planitz
  3.   ------------------------------------------------------------------------
  4.   e-mail address: see CONST "e_mail"
  5.  
  6.  
  7.   The source and the compiled EXE-file can be freely distributed as long as
  8.   no changes are made without my knowledge.
  9.  
  10.   --------------------------------
  11.   Notes:
  12.    The program was tested with INTLIST38 and INTLIST39 and its output
  13.      was successfully compiled with the MS-Help-compiler "HC31.EXE" V3.10.445.
  14.  
  15.    The program needs the file "INTWHLP.DAT" in the 'source' directory.
  16.  
  17.    The program converted all sourcefiles (INTERRUP.* and *.LST) to
  18.      13 RTF files which needed 11MB on my harddrive.
  19.  
  20.    Compiling the RTF-files without compression took 13 minutes in
  21.      a DOS-Window under Win/NT on a 486-50 (if you run it under DOS
  22.      and if you have a fast hardrive cache, it might be faster).
  23.  
  24.    The (uncompressed) compiled HLP-File was approximately 7MB large.
  25.    If you want to create a compressed HLP-file, you have to exchange the
  26.      comments in the generated help-project file ("RB.HPJ"). Compressing
  27.      reduces the size of the HLP-file to 3MB but it takes
  28.      *more* (?? 28MB ??)  space on your harddrive while compiling.
  29.      In order to speed up compiling the compressed file, I've included a
  30.      temporary file ("INTWIN.PH") of the helpcompiler in this archive.
  31.      Copy this file into the directory containing all the RTF files
  32.      before starting the compiler. This file is specific for INTERLIST39, so
  33.      if you want to get maximal compression in future versions, remove it.
  34.  
  35.    After the compilation finishes, you will find the file "INTWIN.HLP".
  36.      Start Windows, create an icon in the program manager and double-click on it.
  37.  
  38.    Version 1.11:
  39.    The compressed INTWIN.HLP file compiled from Ralf Brown's Interrupt List
  40.      release 42 occupies appr. 4.6 MB.
  41.  
  42.   --------------------------------
  43.  
  44.    If you find this program usefull, if it does not work or if you have ideas
  45.    how to expand its functionality, feel fee to write an e-mail to me.
  46.  
  47.    As usual, I do not take any responsibility for possible damages done by
  48.    this program.
  49.  
  50.  
  51.   Two questions and their answers :
  52.   ---------------------------------
  53.    WHY is the HLP-file so large ?
  54.      In contrast to other programs that convert the interrupt list to
  55.      DOS-based hypertext systems, this program generates a large
  56.      index file that allows you to search for keywords.
  57.  
  58.    WHY did I wrote this program in Pascal and not in C ?
  59.      I think Pascal is a pretty nice language for small projects.
  60.      Another reason is the availability of efficient string handling under Pascal.
  61. *)
  62.  
  63. {$A+,B-,D+,E-,F-,I+,L+,N-,O-,R-,S-,V-}
  64. {$M 16384,25000,200000}
  65. (* minimum heap estimate (1994): 60*(6+10)+(30+40)*(43+10)+50*256=16770 *)
  66. (* (average entry size times (number of entries + 10) for FLAGS, CATEGORIES,
  67.    and CATEGORYKEYS entries) or times 256 for titles.
  68.    Each string in the [*ALIASES] sections requires (length of string) + 5.
  69. *)
  70.  
  71. Program INT2WHLP;
  72.  
  73. uses DOS;
  74.  
  75. { Version 1.00 - 1994
  76.   v. 1.01 -
  77.   v. 1.01a - 1994-02-16:
  78.     published with Ralf Brown's Interrupt List release 40.
  79.   v. 1.02 - 1994-04-07:
  80.     Changed program name from RB2HLP/INTWHLP to INT2WHLP.
  81.     Reduced the amount of RTF control codes.
  82.     Introduced program parameter controlled behaviour.
  83.     Improved flexibility by use of constants for parts of the control.
  84.     Changed and added some windows.
  85.     Extended search key facilities.
  86.   v. 1.03 - 1994-04-17:
  87.     Expanded/Compressed index switch.
  88.     Multi columns compressed index.
  89.     Interrupt titles OVERVIEW.LST.
  90.   v. 1.04 - 1994-04-29:
  91.     Configuration file including:
  92.       Program parameters can be defined in the configuration file. Such
  93.         definitions are overriden by program parameters.
  94.       Several WINHELP parameters, like font and size, can be specified.
  95.       Supplementary information "windows" can be included.
  96.       An ALIAS list can be compiled and written to the HPJ file.
  97.       A BUILDTAG list can be copied from the configuration to the HPJ file.
  98.   v. 1.05 - 1994-05-07:
  99.     Reconsidered default directories.
  100.   v. 1.06 - 1994-05-26:
  101.     Cross-references to tables.
  102.   v. 1.07 - 1994-05-29:
  103.     Edited procedure explain.
  104.     Skip "Section" file break sections (from a "--------!-Section--.."
  105.       divider line up to the next divider line).
  106.     Executable code released with Interrupt List release 41.
  107.     (ProgVers erroneously = '1.06').
  108.   v. 1.08 - 1994-07-10:
  109.     Tables as separate topics.
  110.   v. 1.10 - 1994-07-20:
  111.     Interrupt List release number dependent compilation.
  112.     Published with Interrupt List release 42.
  113.   v. 1.11 - 1994-09-20:
  114.     [INTWINCONFIG] section in configuration file.
  115.   v. 1.12 - 1994-11-04:
  116.     Test for long graphics lines in ReadLine().
  117.     Published with Interrupt List release 43.
  118.   v. 1.13 - 1994-12-26:
  119.     Transformation of DOS graphics in ReadLine().
  120.     Check for duplicate keywords (from CATEGORYKEYS) in NewHlpPage().
  121.     Secondary register references as keywords.
  122.     Separate RTF files for interrupts and tables, check for direct/inderect
  123.       references to tables from current interrupt.
  124.   v. 1.14 - 1995-03-07:
  125.     Return errorlevel 1 for warnings and >= 2 for errors.
  126.   v. 1.15 - 1995-05-29:
  127.     Avoid empty topic in the beginning of .RTF files.
  128.         Made more tools-tolerant: RTF files for expanded and compressed
  129.         indexes reversed. It is easier for some tools to digest the very
  130.         long expanded index when it is compiled at a later state so all its
  131.         phrases are already known.
  132.     [BAGGAGE] section handling.
  133.     Expanded list of registered warnings.
  134.     Copyright message and credits window include Bent Lynggaard as
  135.     coauthor.
  136.   v. 1.16 - 1995-07-31:
  137.     Christian's new e-mail address.
  138.   v. 1.17 - 1996-01-25:
  139.     Fixed bug in NewHlpPage (bad search keys for AH = xx + secondary reg.).
  140.         Switch to inhibit long search keys for INT topics (in order to support
  141.         limited capacity in WinHelp 4.0).
  142.   v. 1.18 - 1996-10-05:
  143.     Shortcut from Credits topic to Interrup.1st Contact Info.
  144.         Insert icon interrup.ico if it is available in current, INT2WHLP home,
  145.         or source directory.
  146.         intwin.ph no longer included in package, instead download interNNz.zip.
  147.   v. 1.19 - 1997-07-01:
  148.     Returns warning errorlevel if ProcessFile() fails.
  149.     Fixed bug: failed to convert non-ASCII characters in table headers.
  150.   v. 1.20 - 1997-12-15:
  151.     Bug fix: Failed to print backward reference after file sectioning.
  152.         Option -KT: Tabel search string in separate keyword table.
  153.   v. 1.21 - 1998-03-01:
  154.     Fixed two errors introduced in v. 1.20 bugfix: v. 1.20 terminated
  155.         after file section break in concatenated interrup.lst file compilation,
  156.         and it could scramble extended register information.
  157. }
  158.  
  159. const
  160.   progName  = 'INT2WHLP';
  161.   progVers  = '1.21';
  162.   hfName    = 'INTWIN'; { helpfile name }
  163.   copyright = 'Copyright (C) 1994-1997 by Christian Müller-Planitz and Bent Lynggaard';
  164.   e_mail    = '"cmp@cs.utah.edu"';
  165.     { e-mail address in Intro/Explain windows }
  166.   e_mailCredits = '"cmp@cs.utah.edu"';
  167.     { e-mail address in the Credits window }
  168.   e_mailCredits2 = '"bent.lynggaard@risoe.dk"';
  169.     { e-mail address in the Credits window, coauthor }
  170.  
  171.   { the strings ack01 ... are displayed in the Credits window }
  172.  
  173.   { thanks to (excuse the format): }
  174.   ack01 = '';
  175. (* The following line is a template for an entry:
  176.   '\par{\b <name>} <reason for the entry>';
  177. *)
  178.   ack02 = '';
  179.   ack03 = '';
  180.   ack04 = '';
  181.   ack05 = '';
  182.   {if extended, update procedure "Credits"}
  183.  
  184.   {"errorlevel" constants:}
  185.   aliasErr    = 241; (* alias not found, or table exceeded *)
  186.   fileErr    = 242; (* cannot open file *)
  187.   formatErr    = 243; (* table exceeded, or fatal error in input file *)
  188.   paramErr    = 244; (* error in program parameter *)
  189.   rtfErr    = 245; (* unable to open output file *)
  190.   userErr    = 240; (* terminated by user *)
  191.  
  192. {$I INT2WHLP.INC }
  193.  
  194.   Procedure NewHlpPage(VAR F : Text; S, ID, BrowseID : String; Classification : Char);
  195.     label
  196.       deleteDone, insertKey;
  197.     type
  198.       intRec = record (* used for fast test and transfer of string *)
  199.     ln: byte;    (* string length *)
  200.     l: longint;  (* 'INT ' *)
  201.     n: word;     (* 'nn' *)
  202.     c7: char;    (* ' ' *)
  203.     l2: longint; (* 'ahal' or 'List' *)
  204.     c12: char;   (* ' ' *)
  205.     w: word;     (* '- ' *)
  206.       end; (* record intRec *)
  207.       nnRec = record ln: byte; w: word; (* for 'nn' *) end;
  208.       ahalRec = record ln: byte; l: longint; (* for 'ahal' *) end;
  209.     const
  210.       linebreak = #13#10'\par\tab';
  211.       intC = ord('I')+ord('N')*$100+ord('T')*$10000+ord(' ')*$1000000;
  212.       listC = ord('L')+ord('i')*$100+ord('s')*$10000+ord('t')*$1000000;
  213.       sepC = ord('-')+ord(' ')*$100;
  214.       int:  string[3] = 'nn';   (* preset length to 2, never changed *)
  215.     VAR
  216.       intR: nnRec absolute int; (* type cast *)
  217.       p,q : Word;
  218.       func: string[5];
  219.       funcR: ahalRec absolute func; (* type cast *)
  220.       ss: string;
  221.       ssR: intRec absolute ss;
  222.  
  223.     Procedure FootNote(Note: Char; ID : String);
  224.       begin
  225.     writeln(F, '{', Note,'}{\footnote ',Note,' ', ID, '}');
  226.       end;
  227.  
  228.     procedure insertInt;
  229.       begin
  230.     insert('INT '+int+equStr+func+';'+int+' '+func+';',ss,11);
  231.       (* "INT nn Ar = XXxx;nn XXxx;"  (XXxx = ahal, ah, or --al) *)
  232.     if equStr[3]='L' then delete(ss,21+equBlanks,2);
  233.       (* "--" from AL = --al *)
  234.     insert(copy(ss,18,6+equBlanks+2*ord(equStr[3]='X')),ss,11);
  235.       (* "Ar = XXxx;" *)
  236.       end; (* procedure insertInt in NewHlpPage *)
  237.     procedure insertSecReg(p, l: word);
  238.     (* duplicates part of SS and inserts secondary register *)
  239.       begin
  240.     insert(copy(ss,p,l),ss,p); (* duplicate *)
  241.     insert(secReg,ss,p+l+l-1); (* SXnnnn *)
  242.     insert(secReg,ss,p+l+p-5);
  243.     insert(equStr2,ss,p+l+p-2); (* SX = nnnn *)
  244.     insert(copy(secReg,2,7)+';',ss,p);   (* SXnnnn; *)
  245.     insert(equStr2,ss,p+2);    (* SX = nnnn; *)
  246.       end; (* procedure insertSecReg in NewHlpPage *)
  247.  
  248.     begin
  249.       PageRTF(F); (* insert '\page' if appropriate *)
  250.       writeln(F, '\pard\keepn\li'+indent+'\fi-'+indent);
  251.       FootNote('#', ID);
  252.       if S<>'' then FootNote('$', S);
  253.       if BrowseID<>'' then FootNote('+', BrowseID);
  254.       if (Classification <> nullClassification) then begin
  255.     ss:=s;
  256.     if Classification=titleOnlyClassification then goto insertKey;
  257.     if (ssR.l=intC) AND (ssR.c7=' ') then begin
  258.       if (length(ss)>14) AND (ssR.c12=' ') AND (ssR.w=sepC) then begin
  259.         (* insert highlight in s *)
  260.         insert('}}',s,7);
  261.         insert('{'+highlightInt+'{',s,1);
  262.           (* 2nd '{' terminates attribute, a ' ' distorts if attrib. is empty *)
  263.         (* insert tiny, short, and full form of INT *)
  264.         intR.w:=ssR.n;   (* length of "int" is preset to 2 *)
  265.         (* same as "int:=copy(ss,5,2);": nn from INT nn ahal - xxxx ... *)
  266.         funcR.l:=ssR.l2;
  267.         funcR.ln:=4;     (* func = 'ahal' *)
  268.         ss[7]:=';';      (* INT nn;ahal - xxxx ... *)
  269.         ss[8]:=int[1];
  270.         ss[9]:=int[2];
  271.         ss[10]:=';';     (* INT nn;nn;l - xxxx ... *)
  272.         delete(ss,11,4); (* INT nn;nn;xxxx ... *)
  273.         if func<>'----' then begin
  274.           if func[3]='-' then begin equStr[3]:='H'; func[0]:=#2; end
  275.           else if func[1]='-' then equStr[3]:='L'
  276.           else equStr[3]:='X';
  277.           insertInt;
  278.     (* INT nn;nn;AX = ahal;INT nn AX = ahal;nn ahal;xxxx ... or
  279.        INT nn;nn;AH = ah;INT nn AH = ah;nn ah;xxxx ... or
  280.        INT nn;nn;AL = al;INT nn AL = al;nn --al;xxxx ...
  281.     *)
  282.           if equStr[3]='H'then begin
  283.         insert(copy(ss,29+equBlanks+equBlanks,6)+'--',
  284.           ss,35+equBlanks+equBlanks);
  285.         insert('AX'+equStr2+copy(ss,39+equBlanks+equBlanks,5),
  286.           ss,44+equBlanks+equBlanks);
  287. (* INT nn;nn;AH = ah;INT nn AH = ah;nn ah;nn ah--;AX = ah--;xxxx ... *)
  288.           end; (* equStr[3]='H' *)
  289.           (* duplicate INT nn Ar = ... and insert secondary register
  290.          if appropriate.
  291.           *)
  292.           if secReg<>'' then case equStr[3] of
  293.         'X': insertSecReg(19+equBlanks, 23+equBlanks);
  294.         'H': insertSecReg(17+equBlanks, 19+equBlanks);
  295.         else insertSecReg(17+equBlanks, 21+equBlanks);
  296.           end; (* if secReg<>'' then case equStr[3] of *)
  297.           if equStr[3]='X' then begin (* insert also the AH values *)
  298.         equStr[3]:='H';
  299.         func[0]:=#2;
  300.         insertInt;
  301. (* INT nn;nn;AH = ah;INT nn AH = ah;nn ah;AX = ahal;INT nn AX = ahal;nn ahal;xxxx ... *)
  302.           end; (* if equStr[3]='X' *)
  303.         end (* if func<>'----' *)
  304.         else if secReg<>'' then insertSecReg(1, 10);
  305.         if NOT longKeys then repeat
  306.         (* disable long keys by deleting them. It is not very efficient
  307.            to insert search keys and then delete them again, however,
  308.            this was introduced at a late state due to restrictions in
  309.            WinHelp v. 4.00, and implemented the easy way. The long and
  310.                short formats in the preceding code are so integrated that
  311.                it would take hours to write a more efficient implementation.
  312.         *)
  313.           p:=pos('INT ',ss);
  314.           if p=0 then goto deleteDone;
  315.           q:=p+5;
  316.           while ss[q]<>';' do inc(q);
  317.           delete(ss,p,succ(q-p));
  318.         until false;
  319.     deleteDone:
  320.       end (* if length(ss)>14 ... *)
  321.       else if (length(s)=11) and (ssR.l2=listC) then begin
  322.         insert(copy(ss,1,6)+';',ss,1); (* INT nn;INT nn List *)
  323.         insert(copy(ss,5,3),ss,8); (* INT nn;nn;INT nn List *)
  324.       end; (* else if ... *)
  325.     end; (* if (ssR.l=intC) ... *)
  326.     if Classification=tableClassification then begin
  327.       delete(ss,1,8); (* 'II SUBF ' *)
  328.       footnote(tableKWT,'#'+currentTable);
  329.       if highestTableNumber<currentTable then highestTableNumber:=currentTable;
  330.     end (* if Classification=tableClassification *)
  331.     else repeat
  332.       p := POS(' - ', ss);
  333.       if p <> 0 then
  334.         begin
  335.           ss[p] := ';';
  336.           delete(ss,succ(p),2);
  337.         end;
  338.     until p=0;
  339.     if (Classification <> InvalidClassification)
  340.         AND (Classification > ' ') then begin
  341.       if categoryKeyStrings[Classification]^<>'' then begin
  342.         (* check for duplicate before inserting *)
  343.         p:=pos(categoryKeyStrings[Classification]^,ss);
  344.         q:=length(categoryKeyStrings[Classification]^);
  345.         if (p=0) OR ((p+q<>length(ss)) AND (ss[p+q]<>';')) then
  346.           insert(categoryKeyStrings[Classification]^+';',ss,1);
  347.       end; (* if categoryKeyStrings[Classification]^<>'' *)
  348.       if (Classification<'A') OR (Classification>'Z') then
  349.         insert(Classification+';',ss,1)
  350.       else insert(Classification+'!;',ss,1);
  351.     end; (* if (Classification<>InvalidClassification) ... *)
  352.       insertKey:
  353.     FootNote('K', SS);
  354.       end; (* if (Classification<>nullClassification) *)
  355.  
  356.       write(F, '{\f0'+headerAttrib,headerSize,' ');
  357.       if classification=specialClassification then write(F, indexHeader);
  358.       writeln(F, S,'}');
  359.       writeln(F, '\par\pard\keep');
  360.     end;
  361.  
  362.   Procedure AddTopic(VAR F: Text; ST, S, ID: String);
  363.   { print: ST as a string (normally "\par " for new line), S as a hotspot,
  364.     ID as the corresponding jump address or macro.
  365.   }
  366.     const sp: array[0..7] of string[7] =
  367.       ('       ','      ','     ','    ','   ','  ',' ','');
  368.     var p: integer;
  369.     begin
  370.       repeat
  371.     (* detab S, otherwise the string cannot be selected with the cursor
  372.        in a tab position.
  373.     *)
  374.     p:=pos(#9,S);
  375.     if p<>0 then begin S[p]:=' '; insert(sp[(p-1) AND 7],S,p); end;
  376.       until p=0;
  377.       writeln(F, ST,'{\uldb ', S, '}{\v ', ID, '}');
  378.     end;
  379.  
  380.   Procedure CheckKeyWords(VAR s : STring);
  381.     CONST KeyWords = 11;
  382.     CONST Keys : Array[1..KeyWords] of String[10] = ('Desc:', 'Notes:',
  383.       'Note:', 'Warning:', 'Index:', 'SeeAlso:', 'Return:', 'BUG:', 'BUGS:',
  384.       'Program:', 'Range:');
  385.     CONST IStr = '{\b ';
  386.     VAR q,p : Integer;
  387.  
  388.     begin
  389.       if length(s)<251 then for q:= 1 to KeyWords do begin
  390.     p := POS(Keys[q], S);
  391.     if p <> 0 then begin
  392.       insert(IStr, S, p);
  393.       insert('}', S, p+Length(Keys[q]) + Length(IStr));
  394.       exit;
  395.     end;
  396.       end;
  397.     end;
  398.  
  399.   Function GetSpecialNote(Note : Char)  : String;
  400.     begin
  401.       if flagStrings[Note]^='' then GetSpecialNote:='<unknown note in header>'
  402.       else GetSpecialNote:=flagStrings[Note]^;
  403.     end;
  404.  
  405. procedure insertQueued;
  406.   var i,j: word;
  407.   begin
  408.     if (indexColumns>1) OR (queuedEntry='') then exit;
  409.     val('$'+lastSection,i,j);
  410.     if singlesInMain AND (INTcounts[i]=1) then
  411.       AddTopic(IndexFile, nl, queuedEntry, lastSection+'_1')
  412.     else AddTopic(IndexFile, nl, title, lastSection+'_0');
  413.     queuedEntry:='';
  414.   end; (* procedure insertQueued *)
  415.  
  416. function inArray(n: integer; var arr: tableArray; var top: integer): boolean;
  417. (* returns true if n is in arr, else false *)
  418.   var i: integer;
  419.   begin
  420.     i:=1;
  421.     while (i<=top) AND (arr[i]<>n) do inc(i);
  422.     inArray:=i<=top;
  423.   end; (* function inArray *)
  424.  
  425. procedure toArray(n: integer; var arr: tableArray; var top: integer);
  426. (* inserts n in arr if not already present *)
  427.   begin
  428.     if inArray(n, arr, top) then exit;
  429.     if top=tableArraySize then errorExit('Table array exceeded',formatErr);
  430.     inc(top);
  431.     arr[top]:=n;
  432.   end; (* procedure toArray *)
  433.  
  434. Function ProcessIntList(FName : PathStr) : Boolean;
  435.   LABEL STOP, error_Exit, endOfLoop, table, fobi, noTable;
  436.   type
  437.     kind = (firstPart,inOverview,inFlags,inCategories,inKeys,
  438.       inFileBreakSection,pastTest);
  439.     tableId = array[1..4] of char;
  440.     sRec = record
  441.       l: byte; (* length *)
  442.       w: word; (* with '(T' *)
  443.       d: longint; (* with 'able' *)
  444.       c1: char; (* ' ' *)
  445.       ti: tableId;
  446.       c2: char; (* ')' *)
  447.     end; (* record sRec *)
  448.     castRec = record
  449.       l: byte;
  450.       case byte of
  451.     1: (w: word);
  452.     2: (d: longint);
  453.     3: (c: char (* space *); r: word; rv: longint);
  454.     end; (* record castRec *)
  455.     dividerRec = record
  456.       s: string[8];    (* '--------' *)
  457.       cat: char;    (* category *)
  458.       c: char;    (* '-' *)
  459.       w: word;    (* Interrupt number, 2 hex digits *)
  460.       d: longint;    (* sub function, 4 hex digits or '-' *)
  461.       r: word;    (* secondary register name, two letters or '--' *)
  462.       rv: longint;    (* sec. reg. value, 4 hex digits or '-' *)
  463.     end; (* record dividerRec *)
  464.   const
  465.     INTno:     integer = 0;
  466.     bufferString: string = ''; (* transfers part of split string *)
  467.     ta = ord('(')+ord('T')*$100; (* (Table nnnn) *)
  468.     able = ord('a')+ord('b')*$100+ord('l')*$10000+ord('e')*$1000000;
  469.     fo = ord('F')+ord('o')*$100; (* Format of ... *)
  470.     bi = ord('B')+ord('i')*$100; (* Bitfields for ... *)
  471.     Section: String[3] = '--'; (* initialize to length 2 *)
  472.     SubFunc: String[5] = '----'; (* length 4 *)
  473.     allMessages: boolean = false;
  474.  
  475.   VAR
  476.       tP:          ^tableID;
  477.       hLineP,tLineP : ^string; (* pointers to header and (Table) lines *)
  478.       p,q        : integer;
  479.       curTab     : integer;
  480.       lineCount  : word; (* for error report *)
  481.       NewSection : Boolean;
  482.       Classification,c      : Char;
  483.       current    : kind;
  484.       inTable    : boolean;
  485.       table_Id   : String[7];
  486.       tableTitle : String[119];
  487.       s          : String;
  488.       SpecialNote : String;
  489.       sR         : sRec absolute s; (* for type cast *)
  490.       sectionR   : castRec absolute Section;
  491.       subFuncR   : castRec absolute SubFunc;
  492.       secRegR    : castRec absolute secReg;
  493.       dR         : dividerRec absolute s;
  494.       F1         : Text;
  495.  
  496.   function isNumber(var ti: tableId): integer;
  497.   (* returns the table number, or negative value if illegal number *)
  498.     var i,res: integer;
  499.     begin
  500.       res:=0;
  501.       for i:=1 to 4 do case ti[i] of
  502.     '0'..'9': res:=res*10+ord(ti[i])-ord('0');
  503.     else begin isNumber:=-1; exit; end;
  504.       end; (* for ... do case ... *)
  505.       isNumber:=res;
  506.     end; (* function isNumber in function ProcessIntList *)
  507.   procedure insertRef;
  508.     begin
  509.       if inTable then AddTopic(TabTopics,nl,'INT '+Section+' '+SubFunc, TopicStr+mainW)
  510.       else if current<>inFileBreakSection then
  511.     AddTopic(IntTopics,nl,copy(title,1,6),IntTopicStr);
  512.     end; (* procedure insertRef in function ProcessIntList *)
  513.   procedure wrSection; (* show progress *)
  514.     begin write(Section,#13); end;
  515.  
  516.   begin
  517.    {$I-}
  518.     assign(F1, InPath + FName);
  519.     reset(F1);
  520.    {$I+}
  521.     if IOResult <> 0 then begin
  522.       ProcessIntList := FALSE;
  523.       EXIT;
  524.     end;
  525.     writeln('Processing : ', InPath + FName);
  526.     wrSection;
  527.     readLine(F1, s);    { ignore copyright in 1st two lines }
  528.     readLine(F1, s);
  529.     lineCount:=2;
  530.     current:=inFileBreakSection;
  531.     inTable:=false;
  532.     SpecialNote := '';
  533.     while not(EOF(F1)) do begin
  534.       readLine(F1, s);
  535.       inc(lineCount);
  536.       NewSection := (s[1]= '-') and (Pos('--------', s) = 1);
  537.       if NewSection then begin
  538.     if inTable then insertRef;
  539.     for p:=1 to tabTop do begin
  540.       q:=tabArray[p];
  541.       if NOT inArray(q, refArray, refTop) then begin
  542.         str(10000+q,table_Id); (* 1nnnn *)
  543.         delete(table_Id,1,1);  (* nnnn  *)
  544.         AddTopic(intTopics,nl,'Table #'+table_Id,'t'+table_Id+tableW);
  545.         inc(insertCounter);
  546.       end; (* if NOT inArray() *)
  547.     end; (* for p:=1 *)
  548.     inTable:=false;
  549.     insertRef;
  550.     if tabTop>maxTabTop then maxTabTop:=tabTop;
  551.     tabTop:=0;
  552.     if refTop>maxRefTop then maxRefTop:=refTop;
  553.     refTop:=0;
  554.     Classification := s[9];
  555.     if Classification = '!' then begin
  556.       delete(s,1,12);
  557.       q:=0;
  558.       while (s[q] <> '-') and (q < Length(s)) do
  559.         Inc(q);
  560.       s[0] := chr(q-1);  { remove '-' chars at the end }
  561.       if s='OVERVIEW' then current:=inOverview
  562.       else if s='FLAGS' then current:=inFlags
  563.       else if s='CATEGORIES' then current:=inCategories
  564.       else if s='CATEGORYKEYS' then current:=inKeys
  565.       else if s='Section' then begin
  566.         current:=inFileBreakSection;
  567.         goto endOfLoop;
  568.       end (* else if s='Section' *)
  569.       else current:=firstPart;
  570.       (* Interrupt List release 41 does not include OVERVIEW
  571.          and CATEGORYKEYS as sections, but as separate files.
  572.          The program is prepared for this information being
  573.          parts of the List.
  574.       *)
  575.       if s = '' then s:= 'Note';
  576.       if EOF(F1)  then   { last line of document ?}
  577.         goto STOP;
  578.       inc(TopicNo);
  579.       str(TopicNo, TopicStr);
  580.       if lastSection > '-' then section:='--'; (* at end of list *)
  581.     end { if Classification = '!' }
  582.     else begin (* (Classification <> '!') *)
  583.       SectionR.w:=dR.w; (* chars 11..12 of divider line *)
  584.       SubFuncR.d:=dR.d; (* chars 13..16 of divider line *)
  585.       secRegR.r:=dR.r;  (* chars 17..18 of divider line *)
  586.       if secReg[2]='-' then secReg[0]:=#0
  587.       else begin
  588.         secRegR.rv:=dR.rv; (* chars 19..22 of divider line *)
  589.         if secReg[6]='-' then secReg[0]:=#5 else secReg[0]:=#7;
  590.       end; (* else *)
  591.           if section<>lastSection then begin
  592.         val('$'+section,INTno,q);
  593.         if q<>0 then begin
  594.           writeln('Cannot interpret interrupt number in line ',
  595.         lineCount,': "',section,'".');
  596.           goto error_Exit;
  597.         end; (* if q<>0 *)
  598.       end; (* if section<>lastSection *)
  599.       current:=pastTest;
  600.       readLine(F1, s);
  601.       inc(lineCount);
  602.       inc(INTcounts[INTno]);
  603.       str(INTcounts[INTno], TopicStr);
  604.       insert(section+'_',TopicStr,1);
  605. (* We could compare already here: "while aliasString=s do ..." if we want to
  606.    use the orginal interrupt header line to find aliases. However,
  607.      1. it is easier to identify the original position of an alias line,
  608.      2. it is easier to determine the alias sequense in the config. file,
  609.      3. it is easier to track the reason for a "not found" error, and
  610.      4. the chance for an alias line to be unique is higher
  611.    if we compare after the manipulation of the header line. Also, if we copy
  612.    from the INTWIN index rather than from the original list, the lines are
  613.    already manipulated.
  614. *)
  615.     while (s[8] <> '-') do begin { special flags in titel-line ? }
  616.       if s[8] <> ' ' then
  617.         SpecialNote:=SpecialNote+#13#10'\par '+GetSpecialNote(s[8]);
  618.       delete(s, 8, 1);
  619.     end;
  620.         Insert(subFunc+' ', S, 8);
  621.     while aliasString=S do begin
  622.       saveAlias(nextAliasPP,aliasId+TopicStr);
  623.       getNextAlias(aliasP,aliasId,aliasString);
  624.     end; (* while aliasString=S *)
  625.       end; { else (Classification<>'!') }
  626.       if LastSection <> Section then begin
  627.     if Classification = '!' then begin
  628.       if indexColumns=1 then insertQueued;
  629.       IntTopicStr:='N_'+TopicStr;
  630.       title:='Notes';
  631.       if (notesCount MOD indexColumns)=0 then write(IndexFile,'\par ')
  632.       else  write(IndexFile,'\tab ');
  633.       inc(notesCount);
  634.       writeln(IndexFile,'{\uldb Notes}{\v ',IntTopicStr,'}');
  635.     end (* if Classification = '!' *)
  636.     else begin (* (Classification <> '!') *)
  637.       if INTno<lastINTno then begin
  638.         (* we cannot tolerate inconsistent sorting in a
  639.            multi-column index.
  640.         *)
  641.         writeln('Inconsistent sorting in file ',FName,
  642.           ' line ',lineCount);
  643.         writeln('INT ',section,' appears after INT ',lastSection);
  644.         if indexColumns>1 then begin
  645.           wl('This can be tolerated only with a single column index.');
  646.    error_Exit:
  647.           errorExit('Please correct the file and try again.',fileErr);
  648.         end; (* if indexColumns>1 *)
  649.         wl(#7'It is recommended to correct the file.');
  650.       end; (* if INTno<lastINTno *)
  651.       wrSection;
  652.       IntTopicStr:=Section+'_0';
  653.       if indexColumns=1 then begin
  654.         insertQueued;
  655.         queuedEntry:=s;
  656.       end; (* if indexColumns=1 *)
  657.       title:=INTtitles[INTno]^;
  658.       if title='' then title:='INT '+Section;
  659.       lastINTno:=INTno;
  660.         end; (* else (Classification <> '!') *)
  661.     if backRef then AddTopic(SubIntFile,nl,'Interrupts','idInterrupts');
  662.       (* don't insert a backward reference the very first time *)
  663.     backRef:=true; (* but in all the rest *)
  664.     NewHlpPage(SubIntFile, title, IntTopicStr,'i:0', specialClassification);
  665.     if twoIndexes AND indexHeaders then
  666.       OutLn(IntFile,'\par '+title);
  667.     LastSection := Section;
  668.       end; { if LastSection <> Section }
  669.       if TopicNo=1 then c:=specialClassification
  670.     (* The initial Interrupt List section should cary the
  671.        indexHeader.
  672.     *)
  673.       else c:=Classification;
  674.       NewHlpPage(IntTopics, s, TopicStr,'l:0', c);
  675.       if SpecialNote <> '' then    begin
  676.     writeln(IntTopics, '{\cf0 ', SpecialNote, '}'#13#10'\par ');
  677.     SpecialNote := '';
  678.       end; { if SpecialNote <> '' }
  679.       OutLN(IntTopics, '{\cf0 Category: '+ Classification +
  680.     ' - ' + categoryStrings[Classification]^ + '}\par');
  681.       if Classification='!' then setTabs(IntTopics, 8, deciPoints, 10)
  682.     (* we will set tabs in the few Notes, but not in all the
  683.        INT entries.
  684.     *)
  685.       else if markKeys then OutLN(IntTopics,'{\b Inp.:}');
  686.       if twoIndexes then AddTopic(IntFile, indentIndex, s, TopicStr);
  687.       AddTopic(SubIntFile, nl, s, TopicStr);
  688.     end { if NewSection }
  689.     else begin { no new section }
  690.       case current of
  691.     pastTest: begin
  692.   { this paragraph is un-indented to gain space for code }
  693.   if markKeys then CheckKeyWords(s);
  694.   { check the first two characters and react on '(T'[able nnnn)],
  695.     'Fo'[rmat of ...] and 'Bi'[tfields for ...]
  696.   }
  697.   if tables then case sR.w of
  698.     ta: if (length(s)>=12) AND (sR.d=able) AND (sR.c1=' ') AND (sR.c2=')')
  699.       AND (isNumber(sR.ti)>=0) then begin
  700.     hLineP:=@bufferString;
  701.     tLineP:=@s;
  702.   table:
  703.     if eof(F1) then begin
  704.       writeln('Unexpected end of file in table at INT ',Section,
  705.         ' Subfunc ',SubFunc);
  706.       wrSection;
  707.       goto Stop;
  708.     end; (* if eof(F1) *)
  709.     ReadLine(F1, bufferString); (* v. 1.19: rather than readln() *)
  710.     inc(lineCount);
  711.     p:=pos('(Table ',tLineP^);
  712.     if (p=0) OR  (length(tLineP^)<p+11) OR (tLineP^[p+11]<>')')then begin
  713.   noTable:
  714.       inc(missingTableCounter);
  715.       if allMessages OR (missingTableCounter<=missingTableLimit) then begin
  716.         writeln('Missing "(Table nnnn)" in INT ',Section,
  717.           ' Subfunc ',SubFunc,' (line ',lineCount,'):');
  718.         writeln(pred(lineCount):5,s:succ(length(s)));
  719.         writeln(lineCount:5,bufferString:succ(length(bufferString)));
  720.         if missingTableCounter=missingTableLimit then begin
  721.           wl(#13#10'Several missing tables encountered. If '
  722.         +progName+' is used on release 40 or lower');
  723.           wl('of the List, it should be started with the program '
  724.         +'parameter -r40, or with key');
  725.           wl('releaseNo=40 in section [OPTIONS] of the configuration file.');
  726.           write('s=stop; m=messages; else continue without messages: ');
  727.           ProcessTime:=ProcessTime-memL[$40:$6C];
  728.           p:=readKeyWd;
  729.           ProcessTime:=ProcessTime+memL[$40:$6C];
  730.         (* sets ProcessTime "pause" ticks later than original *)
  731.           if word(p)<$100 then writeln (* function key *)
  732.           else begin
  733.         writeln(char(p));
  734.         case upcase(char(p)) of
  735.           'S': errorExit('Terminated by user',userErr);
  736.           'M': allMessages:=true;
  737.         end; (* if ... case ... of *)
  738.           end; (* if word(p)>$ff *)
  739.         end; (* if missingTableCounter=missingTableLimit *)
  740.         wrSection;
  741.       end; (* if allMessages ... *)
  742.       insert(nl,bufferString,1); (* force newline *)
  743.     end (* if (p=0) ... *)
  744.     else begin
  745.       tP:=@tLineP^[p+7];
  746.       curTab:=isNumber(tP^);
  747.       if curTab<0 then goto noTable;
  748.       toArray(curTab, tabArray, tabTop);
  749.       currentTable:=tP^;
  750.       table_Id:='t'+currentTable;
  751.       if inTable then insertRef;
  752.       inTable:=true;
  753.       tableTitle:=Section+' '+SubFunc+' '+hLineP^;
  754.       while tableAliasString=tableTitle do begin
  755.         saveAlias(nextAliasPP,tableAliasId+table_id);
  756.         getNextAlias(tableAliasP,tableAliasId,tableAliasString);
  757.       end; (* while ... *)
  758.       NewHlpPage(TabTopics, tableTitle, table_Id,'t:0', tableClassification);
  759.       if tableWindow then begin
  760.         AddTopic(TabTopics,nl,'Copy to Main',table_Id+mainW);
  761.         OutLn(TabTopics,'');
  762.       end; (* if tableWindow *)
  763.       if sR.w=ta then begin (* bold Table nnnn *)
  764.         s[1]:='{';  (* substitutes '(' *)
  765.         s[12]:='}'; (*   and ')'       *)
  766.         insert('\b ',s,2);
  767.       end (* if sR.w=ta *)
  768.       else begin
  769.         writeln(TabTopics,'\par {\b Table ',currentTable,'}');
  770.         bufferString[0]:=char(pred(p)); (* delete '(Table nnnn)' *)
  771.       end; (* else *)
  772.       AddTopic(TableFile,nl+currentTable+'  ',tableTitle,table_Id);
  773.     end; (* else *)
  774.     end; (* case ta *)
  775.     fo: if pos('Format of ',s)=1 then begin
  776.   fobi:
  777.       hLineP:=@s;
  778.       tLineP:=@bufferString;
  779.       goto table;
  780.     end; (* case fo *)
  781.     bi: if pos('Bitfields for ',s)=1 then goto fobi;
  782.     else begin
  783.       p:=length(s)-4;
  784.       for q:=p downto 1 do begin
  785.     if (s[q]='#') AND ((q=p) OR (s[q+5]<'0') OR (s[q+5]>'9')) then begin
  786.       tP:=@s[q+1];
  787.       curTab:=isNumber(tP^);
  788.       if curTab>=0 then begin
  789.         toArray(curTab, refArray, refTop);
  790.         insert('}{\v t'+tP^+tableW+'}', S, q+5);
  791.         insert('{\uldb ', S, q);
  792.         if (length(s)-q>150) AND (q>20) then begin
  793.           (* we must ensure keeping length(S)<256 *)
  794.           bufferString:=copy(S, q, 255);
  795.           S[0]:=char(pred(q)); (* delete the copied part *)
  796.         end; (* if (length(s)-q>150)... *)
  797.       end; (* if curTab>=0 *)
  798.     end; (* if (s[q]='#')... *)
  799.       end; (* for q=p *)
  800.     end; (* else *)
  801.   end; (* case sR.w of *)
  802.   { indent again }
  803.       end; (* case pastTest *)
  804.       firstPart:    check1st(s);
  805.       inOverview:   getINTtitle(s,INTtitles);
  806.       inFlags:      scan(s,flagStrings);
  807.       inCategories: scan(s,categoryStrings);
  808.       inKeys:       scan(s,categoryKeyStrings);
  809.       inFileBreakSection: goto endOfLoop;
  810.     end; (* case current of *)
  811.     if inTable then OutLN(TabTopics, s) else OutLN(IntTopics, s);
  812.     if bufferString<>'' then begin
  813.       if inTable then OutLn(TabTopics, bufferString) (* with "newline" *)
  814.       else writeln(IntTopics, bufferString); (* no "newline" (\par ) *)
  815.       bufferString:='';
  816.     end; (* if bufferString<>'' *)
  817.       end; { else (no new section) }
  818.   endOfLoop:
  819.     end; { while not(EOF(F1)) }
  820.   STOP:
  821.     if inTable then insertRef;
  822.     inTable:=false;
  823.     insertRef;
  824.     close(F1);
  825.     ProcessIntList := TRUE;
  826.   end;
  827.  
  828. procedure missingFile(var fname: string);
  829.   var dir: dirstr; name: namestr; ext: extstr;
  830.   begin
  831.     fsplit(fname, dir, name, ext);
  832.     writeln(#7'Unable to open ', fname);
  833.     inc(warnings);
  834.     outln(indexFile,
  835.       'Unfortunately, file '+name+ext+' was unavailable at compile time.');
  836.   end; (* procedure missingFile() *)
  837.  
  838.   Procedure NewPage(VAR F: Text; Title : String);
  839.     VAR TopicStr : String;
  840.  
  841.       begin
  842.     Inc(TopicNo);
  843.     str(TopicNo, TopicStr);
  844.     AddTopic(IndexFile, nl, Title, TopicStr);
  845.     NewHlpPage(F, Title, TopicStr,'p:0', InvalidClassification);
  846.     setTabs(F, 8, deciPoints, 10);
  847.       end;
  848.  
  849.   Procedure ProcessPorts(FName : String);
  850.     LABEL STOP;
  851.     VAR i          : integer;
  852.     s          : String;
  853.     TopicStr   : String;
  854.     NewSection : Boolean;
  855.     F1         : Text;
  856.  
  857.     begin
  858.       defaultDir(FName,InPath);
  859.      {$I-}
  860.       assign(F1, FName);
  861.       reset(F1);
  862.      {$I+}
  863.       if IOResult <> 0 then
  864.     begin
  865.       missingFile(FName);
  866.       EXIT;
  867.     end;
  868.  
  869.       writeln('Processing : ', FName);
  870.  
  871.       i:=length(FName);
  872.       while FName[i]<>'\' do dec(i);
  873.       NewPage(IntTopics, copy(FName,succ(i),255)+' Note');
  874.  
  875.       while not(EOF(F1)) do
  876.     begin
  877.       readLine(F1, s);
  878.       NewSection := (s[1]= '-') and (Pos('---------', s) <> 0);
  879.  
  880.       if NewSection then
  881.         begin
  882.           readLine(F1, s);
  883.  
  884.           if EOF(F1)  then   { last line of document ?}
  885.         goto STOP;
  886.  
  887.           if s <> '' then                { why does this happend }
  888.         NewPage(IntTopics, s);
  889.         end
  890.       else
  891.         begin
  892.          CheckKeyWords(s);
  893.          OutLN(IntTopics, s);
  894.         end;
  895.     end;
  896.  
  897.       STOP:
  898.       close(F1);
  899.     end;
  900.  
  901.   Procedure ProcessFile(FName : String; Title : String);
  902.     VAR s          : String;
  903.     F1, F2     : Text;
  904.         interrup1st: boolean;
  905.  
  906.     begin
  907.       defaultDir(FName,InPath);
  908.       interrup1st:=pos('INTERRUP.1ST',FName)<>0;
  909.      {$I-}
  910.       assign(F1, FName);
  911.       reset(F1);
  912.      {$I+}
  913.       if IOResult <> 0 then
  914.     begin
  915.       missingFile(FName);
  916.       if interrup1st then OutLn(IndexFile,
  917.         '{K}{\footnote K interrup.1st Contact Info}'#13#10+
  918.         'For contact information, try keyword '+
  919.         '{\uldb CONTACT_INFO}{\v !JumpKeyword(qchPath,"CONTACT_INFO")}.');
  920.       EXIT;
  921.     end;
  922.  
  923.       writeln('Processing : ', FName);
  924.       setTabs(IndexFile, 8, deciPoints, 10);
  925.  
  926.       while not(EOF(F1)) do
  927.     begin
  928.       readLine(F1, s);
  929.       if interrup1st AND (pos('-CONTACT_INFO-', s)<>0) then
  930.         insert(#13#10'{K}{\footnote K Ralf Brown}'
  931.               +#13#10'{K}{\footnote K Brown, Ralf}'
  932.               +#13#10'{K}{\footnote K CONTACT_INFO}'
  933.               (* the following is used as JumpKeyword() target from Credits *)
  934.               +#13#10'{K}{\footnote K interrup.1st Contact Info}'
  935.               +#13#10, s, 1);
  936.       OutLN(IndexFile, s);
  937.     end;
  938.  
  939.       close(F1);
  940.     end;
  941.  
  942.   Procedure Credits;
  943.     begin
  944.       OutLn(IndexFile,'');
  945.       AddTopic(IndexFile, nl, 'Credits', 'idCredits');
  946.       OutLn(IndexFile,'');
  947.       OutLn(IndexFile,compilationStr);
  948.       NewHlpPage(IndexFile, 'Credits', 'idCredits','m:1', InvalidClassification);
  949.       OutLn(IndexFile,'\pard{\f0'+headerSize+
  950.     '\qc\par Interrupt List (c) by {\b Ralf Brown}'#13#10 { \qc=centered }
  951.         +'{' + header2ndSize + '\par (See '
  952.         +'{\uldb Contact Info in interrup.1st}'
  953.         +'{\v !JumpKeyword(qchPath,"interrup.1st Contact Info")})}\par');
  954.       OutLn(IndexFile,'\par This list was converted from the released ASCII file'#13#10
  955.             + '\par to the Windows Help-Format by \par\par'#13#10
  956.             + '\par {\b Christian M\''81ller-Planitz}'
  957.                     + '{' + header2ndSize + '\par ' + e_mailCredits + '}'
  958.             + '\par and'
  959.                     + '\par {\b Bent Lynggaard}'+header2ndSize);
  960.       OutLn(IndexFile,e_mailCredits2);
  961. (* an alternative format of the last few lines:
  962.             + '\par {\b Christian M\''81ller-Planitz}'
  963.             + '   and   {\b Bent Lynggaard}'+header2ndSize);
  964.       OutLn(IndexFile,e_mailCredits + '  and  ' + e_mailCredits2);}
  965. *)
  966.       if ack01<>'' then begin
  967.     writeIndex('\par\par Thanks to:');
  968.     writeIndex(ack01);
  969.     writeIndex(ack02);
  970.     writeIndex(ack03);
  971.     writeIndex(ack04);
  972.     writeIndex(ack05);
  973.       end; (* if ack01<>'' *)
  974.       writeIndex('\par}');
  975.     end;
  976.  
  977. procedure processTopics(n: integer);
  978. (* inserts references to n topics in the CONTENTS main index *)
  979.   var i: integer; w: string[13]; title,id: string[39];
  980.   begin
  981.     for i:=1 to n do begin
  982.       str(i,w);
  983.       insert('WINDOW ',w,1);
  984.       title:='';
  985.       profileString(w,'title',title,pred(sizeOf(title)));
  986.       id:='';
  987.       profileString(w,'id',id,pred(sizeOf(id)));
  988.       if (title<>'') AND (id<>'') then AddTopic(IndexFile,nl,title,id);
  989.     end; (* for i:=1 *)
  990.   end; (* procedure processTopics *)
  991.  
  992. procedure processPages(n: integer);
  993. (* processes n "windows" as defined in the configuration file *)
  994.   var
  995.     i,j,wType,files,fType: integer;
  996.     w: string[13];
  997.     f: string[17];
  998.     id: string[17];
  999.     fId,chain: string[21];
  1000.     title,fTitle: string[39];
  1001.     fileName: pathStr;
  1002.   begin
  1003.     for i:=1 to n do begin
  1004.       str(i,w);
  1005.       insert('WINDOW ',w,1);
  1006.       title:='';
  1007.       profileString(w,'title',title,pred(sizeOf(title)));
  1008.       id:='';
  1009.       profileString(w,'id',id,pred(sizeOf(id)));
  1010.       if id<>'' then begin
  1011.     wType:=1;
  1012.     profileInt(w,'type',wType);
  1013.     files:=1;
  1014.     profileInt(w,'files',files);
  1015.     case wType of
  1016.       1: NewHlpPage(IndexFile,title,id,'f:0',InvalidClassification);
  1017.         (* Single entry windows *)
  1018.       2: NewHlpPage(IndexFile,title,id,'m:9',InvalidClassification);
  1019.         (* Multi entries windows *)
  1020.       3: ; (* nop *)   (* Windows with own contents list *)
  1021.     end; (* case wType of *)
  1022.     for j:=1 to files do begin
  1023.       str(j,f);
  1024.       insert('file ',f,1);
  1025.       fileName:='';
  1026.       profileString(w,f,fileName,pred(sizeOf(fileName)));
  1027.       if fileName<>'' then begin
  1028.         fType:=wType;
  1029.         profileInt(w,f+' type',fType);
  1030.         case fType of
  1031.           1: ProcessFile(fileName,title);
  1032.           2: ProcessPorts(fileName);
  1033.           3: begin
  1034.         (* the RTF file is expecte to be in:
  1035.              a. the current directory.
  1036.              b. the program's home directory
  1037.            if no drive or root is specified.
  1038.         *)
  1039.         if ((length(fileName)<2) OR (fileName[2]<>':'))
  1040.           AND (fileName[1]<>'\') AND (fileName[1]<>'.') then begin
  1041.           if exist(filename) OR NOT exist(homeDir+filename) then
  1042.             insert(currentDir,filename,1)
  1043.           else insert(homeDir,filename,1);
  1044.         end; (* if (fileName[2]<':'... *)
  1045.         fileName:=fExpand(fileName);
  1046.         if NOT exist(fileName) then begin
  1047.           writeln(#7'File ',fileName,' not found, copy to ',currentDir);
  1048.                   inc(warnings);
  1049.                 end; (* if NOT exist(filename) *)
  1050.         writeln(HPJ,fileName); (* include the file name *)
  1051.           end;
  1052.           4: begin (* ASCII file in multi file entry *)
  1053.         str(j,fTitle);
  1054.         str(j,fId);
  1055.         insert(title+' - ',fTitle,1);
  1056.         insert(id+'_',fId,1);
  1057.         chain:=id+':5';
  1058.         profileString(w,f+' title',fTitle,pred(sizeOf(fTitle)));
  1059.         profileString(w,f+' id',fId,pred(sizeOf(fId)));
  1060.         profileString(w,f+' chain',chain,pred(sizeOf(chain)));
  1061.         NewHlpPage(IndexFile,fTitle,fId,chain,InvalidClassification);
  1062.         defaultDir(fileName,currentDir);
  1063.         ProcessFile(fileName,fTitle);
  1064.           end; (* case 4 *)
  1065.         end; (* case fType of *)
  1066.       end (* if fileName<>'' *)
  1067.       else begin
  1068.         writeln(#7'Missing file name for [',w,'] ',f);
  1069.         inc(warnings);
  1070.       end; (* else *)
  1071.     end; (* for j:=1 *)
  1072.       end (* if (title<>'') ... *)
  1073.       else begin
  1074.     writeln(#7'Missing identifier in ',w);
  1075.     inc(warnings);
  1076.       end; (* else *)
  1077.     end; (* for i:=1 *)
  1078.   end; (* procedure processPages *)
  1079.  
  1080. procedure processFilter;
  1081.   var d: dirStr;
  1082.   begin
  1083.     PageRTF(IndexFile); (* insert '\page' if appropriate *)
  1084.     writeIndex('\pard');
  1085.     writeIndex('#{\footnote{#} idPartComp}');
  1086.     writeIndex('{\f0'+header2ndSize+' This compilation of the Interrupt List does '+#13#10
  1087.       +'not contain all the information in the List, see the '#13#10
  1088.       +'{\uldb INTERRUP.1ST File}{\v id1st} for the availability of the ');
  1089.     writeIndex('complete list.\par\par');
  1090.     writeIndex('See {\uldb Filter Method}{\v idFlt_meth} and '#13#10
  1091.       +'{\uldb Filter File}{\v idFlt_file} for details.\par}');
  1092.     d:=currentDir;
  1093.     if NOT exist('FLT_METH.RTF') then begin
  1094.       if exist(homeDir+'FLT_METH.RTF') then d:=homeDir
  1095.       else begin
  1096.     writeln(#7'File FLT_METH.RTF not found, copy to ',d);
  1097.     inc(warnings);
  1098.       end; (* else *)
  1099.     end; (* if NOT exist() *)
  1100.     writeln(HPJ,d,'FLT_METH.RTF');
  1101.     NewHlpPage(IndexFile, 'Filter File', 'idFlt_file','flt:1', invalidClassification);
  1102.     processFile(filterFileName,'Filter File');
  1103.   end; (* procedure processFilter *)
  1104.  
  1105. procedure readCategoryKeys;
  1106. (* Opens file CATEGORY.KEY if available, and reads definitions to
  1107.    categoryKeyStrings. Definitions are of the type
  1108.       A - definition A, B - definition B,
  1109.    The definitions are inserted as search keys for the appropriate
  1110.    categories. Note that more than one keyword per entry is accepted,
  1111.    separated by a semicolon, e.g. " c - cachers;spoolers,".
  1112.  
  1113.    Reads also title file OVERVIEW.LST.
  1114.  
  1115.    CATEGORY.KEY and OVERVIEW.LST are separate files in Interrupt List
  1116.    release 41+.
  1117. *)
  1118.   var t: text; s: string;
  1119.   begin
  1120. (*$I-*)
  1121.     assign(t,InPath+'category.key');
  1122.     reset(t);
  1123. (*$I+*)
  1124.     if IOresult<>0 then writeln('Unable to open ',InPath,'CATEGORY.KEY')
  1125.     else begin
  1126.       while NOT eof(t) do begin readln(t,s); scan(s,categoryKeyStrings); end;
  1127.       close(t);
  1128.     end; (* else *)
  1129. (*$I-*)
  1130.     assign(t,InPath+'overview.lst');
  1131.     reset(t);
  1132. (*$I+*)
  1133.     if IOresult<>0 then writeln('Unable to open ',InPath,'OVERVIEW.LST')
  1134.     else begin
  1135.       while NOT eof(t) do begin readln(t,s); getINTtitle(s,INTtitles); end;
  1136.       close(t);
  1137.     end; (* else *)
  1138.   end; (* procedure readCategoryKeys *)
  1139.  
  1140. procedure INTsToIndex;
  1141.   var i,j,k,l: word; s: string[3];
  1142.   begin
  1143.     for k:=0 to pred(indexPages) do begin
  1144.       l:=k*indexRows*indexColumns;
  1145.       for i:=0 to pred(indexRows) do begin
  1146.     OutLn(IndexFile, '');
  1147.     for j:=0 to pred(indexColumns) do begin
  1148.       if INTcounts[l+i+j*16]<>0 then begin
  1149.         write(IndexFile,'{\uldb INT ',HEX(l+i+j*16));
  1150.         if indexColumns=4 then write(IndexFile,' List');
  1151.         write(IndexFile,'}{\v ',HEX(l+i+j*16),'_0}');
  1152.       end (* if INTcounts[]<>0 *)
  1153.       else if indexColumns=4 then write(IndexFile,'\tab ');
  1154.       if j<pred(indexColumns) then write(IndexFile,'\tab ');
  1155.     end; (* for j:=0 *)
  1156.       end; (* for i:=0 *)
  1157.       if k<pred(indexPages) then OutLn(IndexFile, '');
  1158.     end; (* for k:=0 *)
  1159.   end; (* procedure INTsToIndex *)
  1160.  
  1161.   const
  1162.     windows: integer = 0;
  1163.  
  1164.   var
  1165.     i: integer;
  1166.     ch: char;
  1167.  
  1168.   begin
  1169.     Intro;
  1170.     if (paramStr(1)='?') OR (paramStr(1)='-?') OR (paramStr(1)='/?')
  1171.       then Explain; (* and exit *)
  1172.  
  1173.     fSplit(paramStr(0),homeDir,currentDir,currentDir);
  1174.       (* works only with DOS 3.30+ - currentDir is used as a dummy *)
  1175.     currentDir:=fExpand('.');
  1176.     if length(currentDir)>3 then begin
  1177.       inc(currentDir[0]);
  1178.       currentDir[length(currentDir)]:='\';
  1179.     end; (* if length()... *)
  1180.     interpretParameters;
  1181.     initializeArrays;
  1182.     nextAliasPP:=@firstAliasP;
  1183.  
  1184.     if InPath='' then begin
  1185.       write('Source directory: ');
  1186.       readln(InPath);
  1187.     end; (* if InPath='' *)
  1188.     if InPath<>'' then begin
  1189.       ch:=InPath[length(InPath)];
  1190.       if (ch<>':') AND (ch<>'\') then
  1191.     begin inc(InPath[0]); InPath[length(InPath)]:='\'; end;
  1192.     end; (* if InPath<>'' *)
  1193.  
  1194.     if OutPath='' then begin
  1195.       write('Dest. directory (has to be created in advance) : ');
  1196.       readln(OutPath);
  1197.     end; (* if OutPath='' *)
  1198.     if OutPath<>'' then begin
  1199.       ch:=OutPath[length(OutPath)];
  1200.       if (ch<>':') AND (ch<>'\') then
  1201.     begin inc(OutPath[0]); OutPath[length(OutPath)]:='\'; end;
  1202.     end; (* if OutPath<>'' *)
  1203.  
  1204.     ProcessTime:=memL[$40:$6C]; { timer ticks since midnight }
  1205.     findDateAndCopyright;
  1206.     CreateHPJ;
  1207.  
  1208.     OpenRTF(IndexFile, 'INDEX.RTF');
  1209.     NewHlpPage(IndexFile, 'Contents:', 'CONTENTS','m:2', specialClassification);
  1210.  
  1211.     readCategoryKeys; (* reads also titles *)
  1212.     OpenRTF(SubIntFile,'SUBINT.RTF');
  1213.     OpenRTF(IntTopics, 'INTTOPIC.RTF');
  1214.     if twoIndexes then OpenRTF(IntFile, 'INT.RTF');
  1215.  
  1216.     if twoIndexes then
  1217.       AddTopic(IndexFile, nl, 'Interrupt Index',
  1218.     '!IfThenElse(IsMark("Compressed_Index"), '
  1219.     +'`JumpId(qchPath,"idInterrupts")'', `JumpId(qchPath,"idIndex")'')')
  1220.     else AddTopic(IndexFile, nl, 'Interrupts', 'idInterrupts');
  1221.     if tables then AddTopic(IndexFile, nl, 'Tables', 'idTables');
  1222.     AddTopic(IndexFile, nl, 'FILELIST', '1');
  1223.     AddTopic(IndexFile, nl, 'INTERRUP.1ST File', 'id1st');
  1224.     if filtered then begin
  1225.       AddTopic(IndexFile, nl, 'Filter Method', 'idFlt_meth');
  1226.       AddTopic(IndexFile, nl, 'Filter File', 'idFlt_file');
  1227.     end; (* if filtered *)
  1228.  
  1229.     profileInt('WINDOWS','number',windows);
  1230.     processTopics(windows); (* insert Ports, Memory etc. in index *)
  1231.  
  1232.     Credits;
  1233.  
  1234.     if twoIndexes then begin
  1235.       NewHlpPage(IntFile, 'Interrupt Index', 'idIndex','m:3', specialClassification);
  1236.       AddTopic(IntFile, nl, 'Compress index',
  1237.     '!SaveMark("Compressed_Index");JumpId(qchPath,"idInterrupts")');
  1238.       { the program adds all following entries }
  1239.     end; (* if twoIndexes *)
  1240.     NewHlpPage(IndexFile, 'Interrupts', 'idInterrupts','m:4', specialClassification);
  1241.     if twoIndexes then begin
  1242.       AddTopic(IndexFile, nl, 'Expand index','!IfThen(IsMark("Compressed_Index"),'
  1243.     +' `DeleteMark("Compressed_Index")'');JumpId(qchPath,"idIndex")');
  1244.       OutLn(IndexFile, '');
  1245.       if indexColumns>1 then setTabs(IndexFile, succ(ord(indexColumns<=4))*8,
  1246.     deciPoints, pred(indexColumns));
  1247.     end; (* if twoIndexes *)
  1248.  
  1249.     if tables then begin
  1250.       OpenRTF(TableFile, 'TABLE.RTF');
  1251.       OpenRTF(TabTopics, 'TABTOPIC.RTF');
  1252.       NewHlpPage(TableFile,'Tables\f1'+fontSize+'\par\par Tab# INT Func Title',
  1253.     'idTables','m:5', invalidClassification);
  1254.       (* "Tab# INT Func Title" in normal text font and size *)
  1255.     end; (* if tables *)
  1256.  
  1257.     profileList('ALIAS',aliasP); (* read [ALIAS] section from config. file *)
  1258.     getNextAlias(aliasP,aliasId,aliasString); (* get the first one (if any) *)
  1259.     profileList('TABLEALIAS',tableAliasP);
  1260.     getNextAlias(tableAliasP,tableAliasId,tableAliasString);
  1261.  
  1262.     (* process either "interrup.lst" or "interrup.a".."interrup.?" *)
  1263.     if NOT ProcessIntList('interrup.lst') then begin
  1264.       ch := 'a';
  1265.       while ProcessIntList('interrup.'+ch) do inc(ch);
  1266.     end; (* if NOT ProcessIntList() *)
  1267.     if NOT longKeys then writeln(HPJ,'SHORTKEY.RTF');
  1268.       (* include short keyword help topic *)
  1269.     if tableKWT<>'K' then begin
  1270.       NewHlpPage(TableFile,'#Table Search','idTableSearch','ts:1',
  1271.     titleOnlyClassification);
  1272.       AddTopic(TableFile,nl,'Enter a table number','!SearchSecondaryKey'
  1273.     +'(hwndApp,qchPath,84,`IntWin Table'',`Enter a four digit table number 0001 - '
  1274.     +highestTableNumber+''',`#'',`'')');
  1275.     (* 84 is ord('T') *)
  1276.       writeln(TableFile,' (seckey.dll required, see details)');
  1277.       AddTopic(TableFile,nl,'Cancel','!back()');
  1278.       AddTopic(TableFile,nl,'Table Search Details','idTableDetails');
  1279.       writeln(HPJ,'TABLEKWT.RTF');
  1280.       (* include table keyword topic *)
  1281.     end; (* if tableKWT<>'K' *)
  1282.  
  1283.     if aliasString<>'' then begin
  1284.       writeln(#7'Alias string not found:'#13#10+'  "',aliasString,'"');
  1285.       inc(warnings);
  1286.       if aliasP<>NIL then
  1287.     wl('One or more alias strings not processed.');
  1288.     end; (* if aliasP<>NIL *)
  1289.     if tableAliasString<>'' then begin
  1290.       writeln(#7'Table alias string not found:'#13#10+'  "',
  1291.     tableAliasString,'"');
  1292.       inc(warnings);
  1293.       if tableAliasP<>NIL then
  1294.     wl('One or more table alias strings not processed.');
  1295.     end; (* if tableAliasP<>NIL *)
  1296.  
  1297.     if indexColumns=1 then insertQueued
  1298.     else INTsToIndex;
  1299.  
  1300.     NewHlpPage(IndexFile, 'INTERRUP.1ST File', 'id1st','f:0', invalidClassification);
  1301.     ProcessFile('interrup.1st', 'INTERRUP.1ST File');
  1302.     if filtered then processFilter;
  1303.  
  1304.     processPages(windows); (* process Ports, Memory etc. *)
  1305.  
  1306.     if firstAliasP<>NIL then begin
  1307.       writeln(HPJ,#13#10'[ALIAS]');
  1308.       processAliasList(firstAliasP);
  1309.     end; (* if (firstAliasP<>NIL)... *)
  1310.     if twoIndexes then closeRTF(IntFile);
  1311.     closeRTF(SubIntFile);
  1312.     closeRTF(IntTopics);
  1313.     if tables then begin
  1314.       closeRTF(TableFile);
  1315.       closeRTF(TabTopics);
  1316.     end; (* if tables *)
  1317.     closeRTF(IndexFile);
  1318.     close(HPJ);
  1319.     if missingTableCounter>=missingTableLimit then
  1320.       writeln(missingTableCounter,' missing tables encountered.');
  1321.     ProcessTime:=memL[$40:$6C]-ProcessTime;
  1322.     writeln('The processing took ',(ProcessTime*10+91) DIV 182,' seconds.');
  1323.       (* 18.2 clock ticks per second, rounded *)
  1324.     i:=(maxTabTop*100) DIV tableArraySize;
  1325.     if i>60 then writeln(i,'% table array usage.');
  1326.     i:=(maxRefTop*100) DIV tableArraySize;
  1327.     if i>60 then writeln(i,'% reference array usage.');
  1328.     if insertCounter<>0 then writeln('Inserted ',insertCounter,' table references.');
  1329.     if warnings<>0 then begin
  1330.       writeln('Issued ',warnings,' warning(s).');
  1331.       halt(1);
  1332.     end; (* if warnings<>0 *)
  1333.   end.
  1334.