home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / inter43 / int2whlp / int2whlp.pas < prev    next >
Pascal/Delphi Source File  |  1994-11-04  |  47KB  |  1,329 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. }
  119.  
  120. const
  121.   progName  = 'INT2WHLP';
  122.   progVers  = '1.12';
  123.   hfName    = 'INTWIN'; { helpfile name }
  124.   copyright = 'Copyright (C) 1994 by Christian Müller-Planitz';
  125.   e_mail    = '"cmuelle@eos.ncsu.edu" or "cmueller@techfak.uni-bielefeld.de"';
  126.     { e-mail address in Intro/Explain windows }
  127.   e_mailCredits = e_mail;
  128.     { e-mail address in the Credits window }
  129.  
  130.   { the strings ack01 ... are displayed in the Credits window }
  131.  
  132.   { thanks to (excuse the format): }
  133.   ack01 = '\par{\b Bent Lynggaard} for ideas, parts of the code, and the "Miscellaneous Information" entry.';
  134.   ack02 = '';
  135.   ack03 = '';
  136.   ack04 = '';
  137.   ack05 = '';
  138.   {if extended, update procedure "Credits"}
  139.  
  140. {$I INT2WHLP.INC }
  141.  
  142.   Procedure NewHlpPage(VAR F : Text; S, ID, BrowseID : String; Classification : Char);
  143.     type
  144.       intRec = record (* used for fast test and transfer of string *)
  145.     ln: byte;    (* string length *)
  146.     l: longint;  (* 'INT ' *)
  147.     n: word;     (* 'nn' *)
  148.     c7: char;    (* ' ' *)
  149.     l2: longint; (* 'ahal' or 'List' *)
  150.     c12: char;   (* ' ' *)
  151.     w: word;     (* '- ' *)
  152.       end; (* record intRec *)
  153.       nnRec = record ln: byte; w: word; (* for 'nn' *) end;
  154.       ahalRec = record ln: byte; l: longint; (* for 'ahal' *) end;
  155.     const
  156.       linebreak = #13#10'\par\tab';
  157.       intC = ord('I')+ord('N')*$100+ord('T')*$10000+ord(' ')*$1000000;
  158.       listC = ord('L')+ord('i')*$100+ord('s')*$10000+ord('t')*$1000000;
  159.       sepC = ord('-')+ord(' ')*$100;
  160.       int:  string[3] = 'nn';   (* preset length to 2, never changed *)
  161.     VAR
  162.       intR: nnRec absolute int; (* type cast *)
  163.       p,q : Word;
  164.       func: string[5];
  165.       funcR: ahalRec absolute func; (* type cast *)
  166.       ss: string;
  167.       ssR: intRec absolute ss;
  168.  
  169.     Procedure FootNote(Note: Char; ID : String);
  170.       begin
  171.     writeln(F, Note,'{\footnote{',Note,'} ', ID, '}');
  172.       end;
  173.  
  174.  
  175.     procedure insertInt;
  176.       begin
  177.     insert('INT '+int+equStr+func+';'+int+' '+func+';',ss,11);
  178.       (* "INT nn Ar = XXxx;nn XXxx;"  (XXxx = ahal, ah, or --al) *)
  179.     if equStr[3]='L' then delete(ss,21+equBlanks,2);
  180.       (* "--" from AL = --al *)
  181.     insert(copy(ss,18,6+equBlanks+2*ord(equStr[3]='X')),ss,11);
  182.       (* "Ar = XXxx;" *)
  183.       end;
  184.  
  185.     begin
  186.       writeln(F, '\page\pard\keepn\li'+indent+'\fi-'+indent);
  187.     (* the '\page' inserted unconditionally here will cause that each .RTF
  188.        file begin with an empty, unreferenced "topic". This is harmless.
  189.        It requires, though, that [OPTIONS] CONTENTS= is defined, or we
  190.        would be left in an empty topic without an exit.
  191.     *)
  192.       FootNote('#', ID);
  193.       if S<>'' then FootNote('$', S);
  194.       if BrowseID<>'' then FootNote('+', BrowseID);
  195.       if (Classification <> nullClassification) then begin
  196.     ss:=s;
  197.     if (ssR.l=intC) AND (ssR.c7=' ') then begin
  198.       if (length(ss)>14) AND (ssR.c12=' ') AND (ssR.w=sepC) then begin
  199.         (* insert highlight in s *)
  200.         insert('}}',s,7);
  201.         insert('{'+highlightInt+'{',s,1);
  202.           (* 2nd '{' terminates attribute, a ' ' distorts if attrib. is empty *)
  203.         (* insert tiny, short, and full form of INT *)
  204.         intR.w:=ssR.n;   (* length of "int" is preset to 2 *)
  205.         (* same as "int:=copy(ss,5,2);": nn from INT nn ahal - xxxx ... *)
  206.         funcR.l:=ssR.l2;
  207.         funcR.ln:=4;     (* func = 'ahal' *)
  208.         ss[7]:=';';      (* INT nn;ahal - xxxx ... *)
  209.         ss[8]:=int[1];
  210.         ss[9]:=int[2];
  211.         ss[10]:=';';     (* INT nn;nn;l - xxxx ... *)
  212.         delete(ss,11,4); (* INT nn;nn;xxxx ... *)
  213.         if func<>'----' then begin
  214.           if func[3]='-' then begin equStr[3]:='H'; func[0]:=#2; end
  215.           else if func[1]='-' then equStr[3]:='L'
  216.           else equStr[3]:='X';
  217.           insertInt;
  218.     (* INT nn;nn;AX = ahal;INT nn AX = ahal;nn ahal;xxxx ... or
  219.        INT nn;nn;AH = ah;INT nn AH = ah;nn ah;xxxx ... or
  220.        INT nn;nn;AL = al;INT nn AL = al;nn --al;xxxx ...
  221.     *)
  222.           if equStr[3]='X' then begin (* insert also the AH values *)
  223.         equStr[3]:='H';
  224.         func[0]:=#2;
  225.         insertInt;
  226. (* INT nn;nn;AH = ah;INT nn AH = ah;nn ah;AX = ahal;INT nn AX = ahal;nn ahal;xxxx ... *)
  227.           end; (* if ar=ax *)
  228.         end; (* if func<>'----' *)
  229.       end (* if length(ss)>14 ... *)
  230.       else if (length(s)=11) and (ssR.l2=listC) then begin
  231.         insert(copy(ss,1,6)+';',ss,1); (* INT nn;INT nn List *)
  232.         insert(copy(ss,5,3),ss,8); (* INT nn;nn;INT nn List *)
  233.       end; (* else if ... *)
  234.     end; (* if (ssR.l=intC) ... *)
  235.     if (Classification <> InvalidClassification)
  236.     AND (Classification > ' ') then begin
  237.       if categoryKeyStrings[Classification]^<>'' then
  238.         insert(categoryKeyStrings[Classification]^+';',ss,1);
  239.       if (Classification<'A') OR (Classification>'Z') then
  240.         insert(Classification+';',ss,1)
  241.       else insert(Classification+'!;',ss,1);
  242.     end; (* if (Classification<>InvalidClassification) ... *)
  243.     if Classification=tableClassification then begin
  244.       delete(ss,1,8); (* 'II SUBF ' *)
  245.       insert('#'+currentTable+';',ss,1);
  246.     end (* if Classification=tableClassification *)
  247.     else repeat
  248.       p := POS(' - ', ss);
  249.       if p <> 0 then
  250.         begin
  251.           ss[p] := ';';
  252.           delete(ss,succ(p),2);
  253.         end;
  254.     until p=0;
  255.     FootNote('K', SS);
  256.       end; (* if (Classification<>nullClassification) *)
  257.  
  258.       write(F, '{\f0'+headerAttrib,headerSize,' ');
  259.       if classification=specialClassification then write(F, indexHeader);
  260.       writeln(F, S,'}');
  261.       writeln(F, '\par\pard\keep');
  262.  
  263.     end;
  264.  
  265.  
  266.   Procedure AddTopic(VAR F: Text; ST, S, ID: String);
  267.   { print: ST as a string (normally "\par " for new line), S as a hotspot,
  268.     ID as the corresponding jump address or macro.
  269.   }
  270.     const sp: array[0..7] of string[7] =
  271.       ('       ','      ','     ','    ','   ','  ',' ','');
  272.     var p: integer;
  273.     begin
  274.       repeat
  275.     (* detab S, otherwise the string cannot be selected with the cursor
  276.        in a tab position.
  277.     *)
  278.     p:=pos(#9,S);
  279.     if p<>0 then begin S[p]:=' '; insert(sp[(p-1) AND 7],S,p); end;
  280.       until p=0;
  281.       writeln(F, ST,'{\uldb ', S, '}{\v ', ID, '}');
  282.     end;
  283.  
  284.  
  285.   Procedure CheckKeyWords(VAR s : STring);
  286.     CONST KeyWords = 11;
  287.     CONST Keys : Array[1..KeyWords] of String[10] = ('Desc:', 'Notes:',
  288.       'Note:', 'Warning:', 'Index:', 'SeeAlso:', 'Return:', 'BUG:', 'BUGS:',
  289.       'Program:', 'Range:');
  290.     CONST IStr = '{\b ';
  291.     VAR q,p : Integer;
  292.  
  293.     begin
  294.  
  295.       for q:= 1 to KeyWords do
  296.     begin
  297.       p := POS(Keys[q], S);
  298.       if p <> 0 then
  299.         begin
  300.           insert(IStr, S, p);
  301.           insert('}', S, p+Length(Keys[q]) + Length(IStr));
  302.           exit;
  303.         end;
  304.     end;
  305.     end;
  306.  
  307.  
  308.   Function GetSpecialNote(Note : Char)  : String;
  309.     begin
  310.       if flagStrings[Note]^='' then GetSpecialNote:='<unknown note in header>'
  311.       else GetSpecialNote:=flagStrings[Note]^;
  312.     end;
  313.  
  314.  
  315. procedure insertQueued;
  316.   var i,j: word;
  317.   begin
  318.     if (indexColumns>1) OR (queuedEntry='') then exit;
  319.     val('$'+lastSection,i,j);
  320.     if singlesInMain AND (INTcounts[i]=1) then
  321.       AddTopic(IntFile, nl, queuedEntry, lastSection+'_1')
  322.     else AddTopic(IntFile, nl, title, lastSection+'_0');
  323.     queuedEntry:='';
  324.   end; (* procedure insertQueued *)
  325.  
  326.  
  327.   Function ProcessIntList(FName : PathStr) : Boolean;
  328.     LABEL STOP, error_Exit, endOfLoop, table, fobi, noTable;
  329.     type
  330.       kind = (firstPart,inOverview,inFlags,inCategories,inKeys,
  331.     inFileBreakSection,pastTest);
  332.       tableId = array[1..4] of char;
  333.       sRec = record
  334.     l: byte; (* length *)
  335.     w: word; (* with '(T' *)
  336.     d: longint; (* with 'able' *)
  337.     c1: char; (* ' ' *)
  338.     ti: tableId;
  339.     c2: char; (* ')' *)
  340.       end; (* record sRec *)
  341.       castRec = record
  342.     l: byte;
  343.     case byte of
  344.       1: (w: word);
  345.       2: (d: longint);
  346.       end; (* record castRec *)
  347.       dividerRec = record
  348.     s: string[8];    (* '--------' *)
  349.     cat: char;    (* category *)
  350.     c: char;    (* '-' *)
  351.     w: word;    (* Interrupt number, 2 hex digits *)
  352.     d: longint;    (* sub function, 4 hex digits or '-' *)
  353.       end; (* record dividerRec *)
  354.     const
  355.       INTno:     integer = 0;
  356.       bufferString: string = ''; (* transfers part of split string *)
  357.       ta = ord('(')+ord('T')*$100; (* (Table nnnn) *)
  358.       able = ord('a')+ord('b')*$100+ord('l')*$10000+ord('e')*$1000000;
  359.       fo = ord('F')+ord('o')*$100; (* Format of ... *)
  360.       bi = ord('B')+ord('i')*$100; (* Bitfields for ... *)
  361.       Section: String[3] = '--'; (* initialize to length 2 *)
  362.       SubFunc: String[5] = '----'; (* length 4 *)
  363.       allMessages: boolean = false;
  364.  
  365.     VAR
  366.     tP:          ^tableID;
  367.     hLineP,tLineP : ^string; (* pointers to header and (Table) lines *)
  368.     p,q        : integer;
  369.     lineCount  : word; (* for error report *)
  370.     NewSection : Boolean;
  371.     Classification,c      : Char;
  372.     current    : kind;
  373.     inTable    : boolean;
  374.     table_Id   : String[7];
  375.     tableTitle : String[119];
  376.     s          : String;
  377.     SpecialNote : String;
  378.     sR         : sRec absolute s; (* for type cast *)
  379.     sectionR   : castRec absolute Section;
  380.     subFuncR   : castRec absolute SubFunc;
  381.     dR         : dividerRec absolute s;
  382.  
  383.     F1, F2        : Text;
  384.  
  385.     function isNumber(var ti: tableId): boolean;
  386.       var i: integer;
  387.       begin
  388.     isNumber:=false;
  389.     for i:=1 to 4 do case ti[i] of '0'..'9': ; else exit; end;
  390.     isNumber:=true;
  391.       end; (* function isNumber in function ProcessIntList *)
  392.     procedure insertRef;
  393.       begin
  394.     if inTable then AddTopic(F2,nl,'INT '+Section+' '+SubFunc, TopicStr+mainW)
  395.     else if IntTopicStr<>'' then AddTopic(F2,nl,copy(title,1,6),IntTopicStr);
  396.       end; (* procedure insertRef in function ProcessIntList *)
  397.     procedure wrSection;
  398.       begin write(Section,#13); end;
  399.  
  400.     begin
  401.      {$I-}
  402.       assign(F1, InPath + FName);
  403.       reset(F1);
  404.      {$I+}
  405.       if IOResult <> 0 then
  406.     begin
  407.       ProcessIntList := FALSE;
  408.       EXIT;
  409.     end;
  410.  
  411.       writeln('Processing : ', InPath + FName);
  412.       OpenOutFile(F2);
  413.       write(LastSection,#13);
  414.  
  415.       readLine(F1, s);    { ignore copyright in 1st two lines }
  416.       readLine(F1, s);
  417.       lineCount:=2;
  418.       current:=firstPart;
  419.       inTable:=false;
  420.  
  421.       SpecialNote := '';
  422.  
  423.  
  424.       while not(EOF(F1)) do
  425.     begin
  426.       readLine(F1, s);
  427.       inc(lineCount);
  428.       NewSection := (s[1]= '-') and (Pos('--------', s) <> 0);
  429.  
  430.       if NewSection then
  431.         begin
  432.           insertRef;
  433.           inTable:=false;
  434.  
  435.           SectionR.w:=dR.w; (* chars 11..12 of divider line *)
  436.           SubFuncR.d:=dR.d; (* chars 13..16 of divider line *)
  437.           Classification := s[9];
  438.           if Classification = '!' then
  439.         begin
  440.           delete(s,1,12);
  441.  
  442.           q:=0;
  443.           while (s[q] <> '-') and (q < Length(s)) do
  444.             Inc(q);
  445.           s[0] := chr(q-1);  { remove '-' chars at the end }
  446.           if s='OVERVIEW' then current:=inOverview
  447.           else if s='FLAGS' then current:=inFlags
  448.           else if s='CATEGORIES' then current:=inCategories
  449.           else if s='CATEGORYKEYS' then current:=inKeys
  450.           else if s='Section' then begin
  451.             current:=inFileBreakSection;
  452.             Section:=LastSection;
  453.             IntTopicStr:='';
  454.             goto endOfLoop; (* skip file break section *)
  455.           end (* if s='Section' *)
  456.           else current:=firstPart;
  457.           (* Interrupt List release 41 does not include OVERVIEW
  458.              and CATEGORYKEYS as sections, but as separate files.
  459.              The program is prepared for this information being
  460.              parts of the List.
  461.           *)
  462.  
  463.           if s = '' then s:= 'Note';   { shit ! }
  464.  
  465.           if EOF(F1)  then   { last line of document ?}
  466.             goto STOP;
  467.           inc(TopicNo);
  468.           str(TopicNo, TopicStr);
  469.         end { if Classification = '!' }
  470.           else
  471.         begin
  472.           if section<>lastSection then begin
  473.             val('$'+section,INTno,q);
  474.             if q<>0 then begin
  475.               writeln('Cannot interpret interrupt number in line ',
  476.             lineCount,': "',section,'".');
  477.               goto error_Exit;
  478.             end; (* if q<>0 *)
  479.           end; (* if section<>lastSection *)
  480.           current:=pastTest;
  481.           readLine(F1, s);
  482.           inc(lineCount);
  483.           inc(INTcounts[INTno]);
  484.           str(INTcounts[INTno], TopicStr);
  485.           insert(section+'_',TopicStr,1);
  486. (* We could compare already here: "while aliasString=s do ..." if we want to
  487.    use the orginal interrupt header line to find aliases. However,
  488.      1. it is easier to identify the original position of an alias line,
  489.      2. it is easier to determine the alias sequense in the config. file,
  490.      3. it is easier to track the reason for a "not found" error, and
  491.      4. the chance for an alias line to be unique is higher
  492.    if we compare after the manipulation of the header line. Also, if we copy
  493.    from the INTWIN index rather than from the original list, the lines are
  494.    already manipulated.
  495. *)
  496.           while (s[8] <> '-') do   { special flags in titel-line ? }
  497.             begin
  498.               if s[8] <> ' ' then
  499.             SpecialNote:=SpecialNote+#13#10'\par '+GetSpecialNote(s[8]);
  500.               delete(s, 8, 1);
  501.             end;
  502.  
  503.           Insert(subFunc+' ', S, 8);
  504.           while aliasString=S do begin
  505.             saveAlias(nextAliasPP,aliasId+TopicStr);
  506.             getNextAlias(aliasP,aliasId,aliasString);
  507.           end; (* while aliasString=S *)
  508.         end; { else (Classification<>'!') }
  509.  
  510.           if LastSection <> Section then
  511.         begin
  512.           if Classification = '!' then begin
  513.             if indexColumns=1 then insertQueued;
  514.             IntTopicStr:='N_'+TopicStr;
  515.             title:='Notes';
  516.             if (notesCount MOD indexColumns)=0 then write(IntFile,'\par ')
  517.             else  write(IntFile,'\tab ');
  518.             inc(notesCount);
  519.             writeln(IntFile,'{\uldb Notes}{\v ',IntTopicStr,'}');
  520.           end (* if Classification = '!' *)
  521.           else begin (* (Classification <> '!'*)
  522.             if INTno<lastINTno then begin
  523.               (* we cannot tolerate inconsistent sorting in a
  524.              multi-column index.
  525.               *)
  526.               writeln('Inconsistent sorting in file ',FName,
  527.             ' line ',lineCount);
  528.               writeln('INT ',section,' appears after INT ',lastSection);
  529.               if indexColumns>1 then begin
  530.             wl('This can be tolerated only with a single column index.');
  531.          error_Exit:
  532.             errorExit('Please correct the file and try again.',1);
  533.               end (* if indexColumns>1 *)
  534.               else wl('It is recommended to correct the file.');
  535.             end; (* if INTno<lastINTno *)
  536.             if INTno<>lastINTno then begin
  537.               wrSection;
  538.               IntTopicStr:=Section+'_0';
  539.               if indexColumns=1 then begin
  540.             insertQueued;
  541.             queuedEntry:=s;
  542.               end; (* if indexColumns=1 *)
  543.               title:=INTtitles[INTno]^;
  544.               if title='' then title:='INT '+Section;
  545.               lastINTno:=INTno;
  546.             end; (* if INTno<>lastINTno *)
  547.           end; (* else (Classification <> '!') *)
  548.  
  549.           if backRef then AddTopic(SubIntFile,nl,'Interrupts','idInterrupts');
  550.             (* don't insert a backward reference the very first time *)
  551.           backRef:=true; (* but in all the rest *)
  552.           NewHlpPage(SubIntFile, title, IntTopicStr,'i:0', specialClassification);
  553.           if twoIndexes AND indexHeaders then
  554.             OutLn(IndexFile,'\par '+title);
  555.           LastSection := Section;
  556.         end; { if LastSection <> Section }
  557.  
  558.  
  559.           if TopicNo=1 then c:=specialClassification
  560.         (* The initial Interrupt List section should cary the
  561.            indexHeader.
  562.         *)
  563.           else c:=Classification;
  564.           NewHlpPage(F2, s, TopicStr,'l:0', c);
  565.           if SpecialNote <> '' then
  566.         begin
  567.           writeln(F2, '{\cf0 ', SpecialNote, '}'#13#10'\par ');
  568.           SpecialNote := '';
  569.         end; { if SpecialNote <> '' }
  570.  
  571.           OutLN(F2, '{\cf0 Category: '+ Classification +
  572.         ' - ' + categoryStrings[Classification]^ + '}\par');
  573.           if Classification='!' then setTabs(F2, 8, deciPoints, 10)
  574.         (* we will set tabs in the few Notes, but not in all the
  575.            INT entries.
  576.         *)
  577.           else if markKeys then OutLN(F2,'{\b Inp.:}');
  578.           if twoIndexes then AddTopic(IndexFile, indentIndex, s, TopicStr);
  579.           AddTopic(SubIntFile, nl, s, TopicStr);
  580.         end { if NewSection }
  581.       else          { no new section }
  582.        begin
  583.          case current of
  584.            pastTest:     begin
  585.       { this paragraph is un-indented to gain space for code }
  586.       if markKeys then CheckKeyWords(s);
  587.       if tables then case sR.w of
  588.     ta: if (length(s)>=12) AND (sR.d=able) AND (sR.c1=' ') AND (sR.c2=')')
  589.       AND isNumber(sR.ti) then begin
  590.         hLineP:=@bufferString;
  591.         tLineP:=@s;
  592.       table:
  593.         if eof(F1) then begin
  594.           writeln('Unextected end of file in table at INT ',Section,
  595.         ' Subfunc ',SubFunc);
  596.           wrSection;
  597.           goto Stop;
  598.         end; (* if eof(F1) *)
  599.         readln(F1, bufferString);
  600.         inc(lineCount);
  601.         p:=pos('(Table ',tLineP^);
  602.         if (p=0) OR  (length(tLineP^)<p+11) OR (tLineP^[p+11]<>')')then begin
  603.       noTable:
  604.           inc(missingTableCounter);
  605.           if allMessages OR (missingTableCounter<=missingTableLimit) then begin
  606.         writeln('Missing "(Table nnnn)" in INT ',Section,
  607.           ' Subfunc ',SubFunc,' (line ',lineCount,'):');
  608.         writeln(pred(lineCount):5,s:succ(length(s)));
  609.         writeln(lineCount:5,bufferString:succ(length(bufferString)));
  610.         if missingTableCounter=missingTableLimit then begin
  611.           wl(#13#10'Several missing tables encountered. If '
  612.             +progName+' is used on release 40 or lower');
  613.           wl('of the List, it should be started with the program '
  614.             +'parameter -r40, or with key');
  615.           wl('releaseNo=40 in section [OPTIONS] of the configuration file.');
  616.           write('s=stop; m=messages; else continue without messages: ');
  617.           ProcessTime:=ProcessTime-memL[$40:$6C];
  618.           p:=readKeyWd;
  619.           ProcessTime:=ProcessTime+memL[$40:$6C];
  620.             (* sets ProcessTime "pause" ticks later than original *)
  621.           if word(p)<$100 then writeln (* function key *)
  622.           else begin
  623.             writeln(char(p));
  624.             case upcase(char(p)) of
  625.               'S': errorExit('Terminated by user',1);
  626.               'M': allMessages:=true;
  627.             end; (* if ... case ... of *)
  628.           end; (* if word(p)>$ff *)
  629.         end; (* if missingTableCounter=missingTableLimit *)
  630.         wrSection;
  631.           end; (* if allMessages ... *)
  632.           insert(nl,bufferString,1); (* force newline *)
  633.         end (* if (p=0) ... *)
  634.         else begin
  635.           tP:=@tLineP^[p+7];
  636.           if NOT isNumber(tP^) then goto noTable;
  637.           insertRef;
  638.           inTable:=true;
  639.           currentTable:=tP^;
  640.           table_Id:='t'+currentTable;
  641.           tableTitle:=Section+' '+SubFunc+' '+hLineP^;
  642.           while tableAliasString=tableTitle do begin
  643.         saveAlias(nextAliasPP,tableAliasId+table_id);
  644.         getNextAlias(tableAliasP,tableAliasId,tableAliasString);
  645.           end; (* while ... *)
  646.           NewHlpPage(F2, tableTitle, table_Id,'t:0', tableClassification);
  647.           if tableWindow then begin
  648.         AddTopic(F2,nl,'Copy to Main',table_Id+mainW);
  649.         OutLn(F2,'');
  650.           end; (* if tableWindow *)
  651.           AddTopic(TableFile,nl+currentTable+'  ',tableTitle,table_Id);
  652.         end; (* else *)
  653.     end; (* case ta *)
  654.     fo: if pos('Format of ',s)=1 then begin
  655.       fobi:
  656.       hLineP:=@s;
  657.       tLineP:=@bufferString;
  658.       goto table;
  659.     end; (* case fo *)
  660.     bi: if pos('Bitfields for ',s)=1 then goto fobi;
  661.     else begin
  662.       p:=length(s)-4;
  663.       for q:=p downto 1 do begin
  664.         if (s[q]='#') AND ((q=p) OR (s[q+5]<'0') OR (s[q+5]>'9')) then begin
  665.           tP:=@s[q+1];
  666.           if isNumber(tP^) then begin
  667.         insert('}{\v t'+tP^+tableW+'}', S, q+5);
  668.         insert('{\uldb ', S, q);
  669.         if (length(s)-q>150) AND (q>20) then begin
  670.           (* we must ensure keeping length(S)<256 *)
  671.           bufferString:=copy(S, q, 255);
  672.           S[0]:=char(pred(q)); (* delete the copied part *)
  673.         end; (* if (length(s)-q>150)... *)
  674.           end; (* if isNumber *)
  675.         end; (* if (s[q]='#')... *)
  676.       end; (* for q=p *)
  677.     end; (* else *)
  678.       end; (* case sR.W of *)
  679.       { indent again }
  680.                  end; (* case pastTest *)
  681.            firstPart:    check1st(s);
  682.            inOverview:   getINTtitle(s,INTtitles);
  683.            inFlags:      scan(s,flagStrings);
  684.            inCategories: scan(s,categoryStrings);
  685.            inKeys:       scan(s,categoryKeyStrings);
  686.            inFileBreakSection: goto endOfLoop;
  687.          end; (* case current of *)
  688.          OutLN(F2, s);
  689.          if bufferString<>'' then begin
  690.            if inTable then OutLn(F2, bufferString) (* with "newline" *)
  691.            else writeln(F2, bufferString); (* no "newline" (\par ) *)
  692.            bufferString:='';
  693.          end; (* if bufferString<>'' *)
  694.        end; { else (no new section) }
  695.  
  696.       endOfLoop:
  697.     end; { while not(EOF(F1)) }
  698.  
  699.       STOP:
  700.       close(F1);
  701.       closeRTF(F2);
  702.       ProcessIntList := TRUE;
  703.     end;
  704.  
  705.  
  706.   Procedure NewPage(VAR F: Text; Title : String);
  707.     VAR TopicStr : String;
  708.  
  709.       begin
  710.     Inc(TopicNo);
  711.     str(TopicNo, TopicStr);
  712.     AddTopic(IndexFile, nl, Title, TopicStr);
  713.     NewHlpPage(F, Title, TopicStr,'p:0', InvalidClassification);
  714.     setTabs(F, 8, deciPoints, 10);
  715.       end;
  716.  
  717.  
  718.   Procedure ProcessPorts(FName : String);
  719.     LABEL STOP;
  720.     VAR i          : integer;
  721.     s          : String;
  722.     TopicStr   : String;
  723.     NewSection : Boolean;
  724.     F1, F2     : Text;
  725.  
  726.  
  727.  
  728.     begin
  729.       defaultDir(FName,InPath);
  730.      {$I-}
  731.       assign(F1, FName);
  732.       reset(F1);
  733.      {$I+}
  734.       if IOResult <> 0 then
  735.     begin
  736.       writeln('Unable to open ', FName);
  737.       EXIT;
  738.     end;
  739.  
  740.       writeln('Processing : ', FName);
  741.       OpenOutFile(F2);
  742.  
  743.       i:=length(FName);
  744.       while FName[i]<>'\' do dec(i);
  745.       NewPage(F2, copy(FName,succ(i),255)+' Note');
  746.  
  747.       while not(EOF(F1)) do
  748.     begin
  749.       readLine(F1, s);
  750.       NewSection := (s[1]= '-') and (Pos('---------', s) <> 0);
  751.  
  752.       if NewSection then
  753.         begin
  754.           readLine(F1, s);
  755.  
  756.           if EOF(F1)  then   { last line of document ?}
  757.         goto STOP;
  758.  
  759.           if s <> '' then                { why does this happend }
  760.         NewPage(F2, s);
  761.         end
  762.       else
  763.         begin
  764.          CheckKeyWords(s);
  765.          OutLN(F2, s);
  766.         end;
  767.     end;
  768.  
  769.       STOP:
  770.       close(F1);
  771.       closeRTF(F2);
  772.     end;
  773.  
  774.  
  775.   Procedure ProcessFile(FName : String; Title : String);
  776.     VAR s          : String;
  777.     F1, F2     : Text;
  778.  
  779.     begin
  780.       defaultDir(FName,InPath);
  781.      {$I-}
  782.       assign(F1, FName);
  783.       reset(F1);
  784.      {$I+}
  785.       if IOResult <> 0 then
  786.     begin
  787.       writeln('Unable to open ', FName);
  788.       EXIT;
  789.     end;
  790.  
  791.       writeln('Processing : ', FName);
  792.       setTabs(IndexFile, 8, deciPoints, 10);
  793.  
  794.       while not(EOF(F1)) do
  795.     begin
  796.       readLine(F1, s);
  797.       OutLN(IndexFile, s);
  798.     end;
  799.  
  800.       close(F1);
  801.     end;
  802.  
  803.  
  804.   Procedure Credits;
  805.     begin
  806.       OutLn(IndexFile,'');
  807.       AddTopic(IndexFile, nl, 'Credits', 'idCredits');
  808.       OutLn(IndexFile,'');
  809.       OutLn(IndexFile,compilationStr);
  810.       NewHlpPage(IndexFile, 'Credits', 'idCredits','m:1', InvalidClassification);
  811.       OutLn(IndexFile,'\pard{\f0'+headerSize+
  812.     '\qc\par Interrupt List (c) by {\b Ralf Brown}\par'); { \qc=centered }
  813.       OutLn(IndexFile,'\par This list was converted from the released ASCII file'
  814.             + '\par to the Windows Help-Format by \par \par'
  815.             + '\par {\b Christian M\''81ller-Planitz}'+header2ndSize);
  816.       OutLn(IndexFile,e_mailCredits); { e-mail address }
  817.       writeIndex('\par\par Thanks to:');
  818.       writeIndex(ack01);
  819.       writeIndex(ack02);
  820.       writeIndex(ack03);
  821.       writeIndex(ack04);
  822.       writeIndex(ack05);
  823.       writeIndex('\par}');
  824.     end;
  825.  
  826.  
  827. procedure processTopics(n: integer);
  828. (* inserts references to n topics in the CONTENTS main index *)
  829.   var i: integer; w: string[13]; title,id: string[39];
  830.   begin
  831.     for i:=1 to n do begin
  832.       str(i,w);
  833.       insert('WINDOW ',w,1);
  834.       title:='';
  835.       profileString(w,'title',title,pred(sizeOf(title)));
  836.       id:='';
  837.       profileString(w,'id',id,pred(sizeOf(id)));
  838.       if (title<>'') AND (id<>'') then AddTopic(IndexFile,nl,title,id);
  839.     end; (* for i:=1 *)
  840.   end; (* procedure processTopics *)
  841.  
  842. procedure processPages(n: integer);
  843. (* processes n "windows" as defined in the configuration file *)
  844.   var
  845.     i,j,wType,files,fType: integer;
  846.     w: string[13];
  847.     f: string[17];
  848.     id: string[17];
  849.     fId,chain: string[21];
  850.     title,fTitle: string[39];
  851.     fileName: pathStr;
  852.   begin
  853.     for i:=1 to n do begin
  854.       str(i,w);
  855.       insert('WINDOW ',w,1);
  856.       title:='';
  857.       profileString(w,'title',title,pred(sizeOf(title)));
  858.       id:='';
  859.       profileString(w,'id',id,pred(sizeOf(id)));
  860.       if (title<>'') AND (id<>'') then begin
  861.     wType:=1;
  862.     profileInt(w,'type',wType);
  863.     files:=1;
  864.     profileInt(w,'files',files);
  865.     case wType of
  866.       1: NewHlpPage(IndexFile,title,id,'f:0',InvalidClassification);
  867.         (* Single entry windows *)
  868.       2: NewHlpPage(IndexFile,title,id,'m:9',InvalidClassification);
  869.         (* Multi entries windows *)
  870.       3: ; (* nop *)   (* Windows with own contents list *)
  871.     end; (* case wType of *)
  872.     for j:=1 to files do begin
  873.       str(j,f);
  874.       insert('file ',f,1);
  875.       fileName:='';
  876.       profileString(w,f,fileName,pred(sizeOf(fileName)));
  877.       if fileName<>'' then begin
  878.         fType:=wType;
  879.         profileInt(w,f+' type',fType);
  880.         case fType of
  881.           1: ProcessFile(fileName,title);
  882.           2: ProcessPorts(fileName);
  883.           3: begin
  884.         (* the RTF file is expecte to be in:
  885.              a. the current directory.
  886.              b. the program's home directory
  887.            if no drive or root is specified.
  888.         *)
  889.         if ((length(fileName)<2) OR (fileName[2]<>':'))
  890.           AND (fileName[1]<>'\') AND (fileName[1]<>'.') then begin
  891.           if exist(filename) OR NOT exist(homeDir+filename) then
  892.             insert(currentDir,filename,1)
  893.           else insert(homeDir,filename,1);
  894.         end; (* if (fileName[2]<':'... *)
  895.         fileName:=fExpand(fileName);
  896.         if NOT exist(fileName) then
  897.           writeln(#7'File ',fileName,' not found, copy to ',currentDir);
  898.         writeln(HPJ,fileName); (* include the file name *)
  899.           end;
  900.           4: begin (* ASCII file in multi file entry *)
  901.         str(j,fTitle);
  902.         str(j,fId);
  903.         insert(title+' - ',fTitle,1);
  904.         insert(id+'_',fId,1);
  905.         chain:=id+':5';
  906.         profileString(w,f+' title',fTitle,pred(sizeOf(fTitle)));
  907.         profileString(w,f+' id',fId,pred(sizeOf(fId)));
  908.         profileString(w,f+' chain',chain,pred(sizeOf(chain)));
  909.         NewHlpPage(IndexFile,fTitle,fId,chain,InvalidClassification);
  910.         defaultDir(fileName,currentDir);
  911.         ProcessFile(fileName,fTitle);
  912.           end; (* case 4 *)
  913.         end; (* case fType of *)
  914.       end (* if fileName<>'' *)
  915.       else writeln(#7'Missing file name for [',w,'] ',f);
  916.     end; (* for j:=1 *)
  917.       end (* if (title<>'') ... *)
  918.       else writeln(#7'Missing title or identifier in ',w);
  919.     end; (* for i:=1 *)
  920.   end; (* procedure processPages *)
  921.  
  922. procedure processFilter;
  923.   var d: dirStr;
  924.   begin
  925.     writeIndex('\page\pard');
  926.     writeIndex('#{\footnote{#} idPartComp}');
  927.     writeIndex('{\f0'+header2ndSize+' This compilation of the Interrupt List does '+#13#10
  928.       +'not contain all the information in the List, see the '#13#10
  929.       +'{\uldb INTERRUP.1ST File}{\v id1st} for the availability of the ');
  930.     writeIndex('complete list.\par\par');
  931.     writeIndex('See {\uldb Filter Method}{\v idFlt_meth} and '#13#10
  932.       +'{\uldb Filter File}{\v idFlt_file} for details.\par}');
  933.     d:=currentDir;
  934.     if NOT exist('FLT_METH.RTF') then begin
  935.       if exist(homeDir+'FLT_METH.RTF') then d:=homeDir
  936.       else writeln(#7'File FLT_METH.RTF not found, copy to ',d);
  937.     end; (* if NOT exist() *)
  938.     writeln(HPJ,d,'FLT_METH.RTF');
  939.     NewHlpPage(IndexFile, 'Filter File', 'idFlt_file','flt:1', invalidClassification);
  940.     processFile(filterFileName,'Filter File');
  941.   end; (* procedure processFilter *)
  942.  
  943. procedure readCategoryKeys;
  944. (* Opens file CATEGORY.KEY if available, and reads definitions to
  945.    categoryKeyStrings. Definitions are of the type
  946.       A - definition A, B - definition B,
  947.    The definitions are inserted as search keys for the appropriate
  948.    categories. Note that more than one keyword per entry is accepted,
  949.    separated by a semicolon, e.g. " c - cachers;spoolers,".
  950.  
  951.    Reads also title file OVERVIEW.LST.
  952.  
  953.    CATEGORY.KEY and OVERVIEW.LST are separate files in Interrupt List
  954.    release 41+.
  955. *)
  956.   var t: text; s: string;
  957.   begin
  958. (*$I-*)
  959.     assign(t,InPath+'category.key');
  960.     reset(t);
  961. (*$I+*)
  962.     if IOresult<>0 then writeln('Unable to open ',InPath,'CATEGORY.KEY')
  963.     else begin
  964.       while NOT eof(t) do begin readln(t,s); scan(s,categoryKeyStrings); end;
  965.       close(t);
  966.     end; (* else *)
  967. (*$I-*)
  968.     assign(t,InPath+'overview.lst');
  969.     reset(t);
  970. (*$I+*)
  971.     if IOresult<>0 then writeln('Unable to open ',InPath,'OVERVIEW.LST')
  972.     else begin
  973.       while NOT eof(t) do begin readln(t,s); getINTtitle(s,INTtitles); end;
  974.       close(t);
  975.     end; (* else *)
  976.   end; (* procedure readCategoryKeys *)
  977.  
  978. procedure INTsToIndex;
  979.   var i,j,k,l: word; s: string[3];
  980.   begin
  981.     for k:=0 to pred(indexPages) do begin
  982.       l:=k*indexRows*indexColumns;
  983.       for i:=0 to pred(indexRows) do begin
  984.     OutLn(IntFile, '');
  985.     for j:=0 to pred(indexColumns) do begin
  986.       if INTcounts[l+i+j*16]<>0 then begin
  987.         write(IntFile,'{\uldb INT ',HEX(l+i+j*16));
  988.         if indexColumns=4 then write(IntFile,' List');
  989.         write(IntFile,'}{\v ',HEX(l+i+j*16),'_0}');
  990.       end (* if INTcounts[]<>0 *)
  991.       else if indexColumns=4 then write(IntFile,'\tab ');
  992.       if j<pred(indexColumns) then write(IntFile,'\tab ');
  993.     end; (* for j:=0 *)
  994.       end; (* for i:=0 *)
  995.       if k<pred(indexPages) then OutLn(IntFile, '');
  996.     end; (* for k:=0 *)
  997.   end; (* procedure INTsToIndex *)
  998.  
  999. procedure initializeArrays;
  1000.   var i: integer; ch: char;
  1001.   begin
  1002.     for ch:='!' to #126 do begin (* default to empty string *)
  1003.       flagStrings[ch]:=@emptyString;
  1004.       categoryStrings[ch]:=@emptyString;
  1005.       categoryKeyStrings[ch]:=@emptyString;
  1006.     end; (* for ch:='!' *)
  1007.     categoryStrings['!']:=@noteString;
  1008.     categoryStrings['-']:=@noneString;
  1009.     for i:=$00 to $FF do begin INTcounts[i]:=0; INTtitles[i]:=@emptyString; end;
  1010.   end; (* procedure initializeArrays *)
  1011.  
  1012. procedure findDateAndCopyright;
  1013.   var a,b,c,d: word; s,ss: string[99]; t: text;
  1014.   begin
  1015.     getDate(a,b,c,d);
  1016.     (*$ifdef m_dd_yy *)
  1017.       str(b*1000000+(c*1000+a MOD 100),dateString);
  1018.       dateString[length(dateString)-5]:=dateSep;
  1019.       dateString[length(dateString)-2]:=dateSep;
  1020.     (*$else*)
  1021.       (*$ifdef d_mm_yy *)
  1022.     str(c*1000000+(b*1000+a MOD 100),dateString);
  1023.     dateString[length(dateString)-5]:=dateSep;
  1024.     dateString[length(dateString)-2]:=dateSep;
  1025.       (*$else*)
  1026.     str(a*1000000+(b*1000+c),dateString);
  1027.     dateString[5]:=dateSep;
  1028.     dateString[8]:=dateSep;
  1029.     (*$ifdef yy_mm_dd *) delete(dateString,1,2); (*$endif*)
  1030.       (*$endif*)
  1031.     (*$endif*)
  1032.     getTime(a,b,c,d);
  1033.     str((a*1000+b)+100000,s);
  1034.     s[4]:=timeSep;
  1035.     s[1]:=' ';
  1036.     if a<10 then delete(s,2,1);
  1037.     dateString:=dateString+' -'+s;
  1038.   (*$I-*)
  1039.     assign(t,InPath+'interrup.lst');
  1040.     reset(t);
  1041.     if IOresult<>0 then begin
  1042.       assign(t,InPath+'interrup.a');
  1043.       reset(t);
  1044.       if IOresult<>0 then
  1045.     errorExit('Unable to open INTERRUP file in directory '+InPath,1);
  1046.     end; (* if IOresult<>0 *)
  1047.   (*$I+*)
  1048.     ReadLine(t,s);
  1049.     ReadLine(t,ss);
  1050.     close(t);
  1051.     for a:=1 to 2 do begin
  1052.       b:=pos(#9,s); (* remove two wide areas of whitespace *)
  1053.       if b<>0 then while s[b]=#9 do delete(s,b,1)
  1054.       else begin
  1055.     b:=pos('        ',s);
  1056.     if b<>0 then while s[b]=' ' do delete(s,b,1)
  1057.       end; (* else *)
  1058.       if b<>0 then insert('      ',s,b); (* insert 6 spaces instead *)
  1059.     end; (* for a:=1 *)
  1060.     indexHeader:='{\keep '+s+#13#10'\par{'+header2ndSize+' '+ss+'}'#13#10'\par';
  1061.     if scrollIndexTitle then indexHeader:=indexHeader+'\pard';
  1062.     indexHeader:=indexHeader+#13#10'\par}';
  1063.     compilationStr:=progName+' v. '+progVers+' compilation.'#13#10'\par '
  1064.       +hfName+'.HLP compiled '+dateString+'.';
  1065.     if filtered then compilationStr:=compilationStr
  1066.       +' {\ul Partial compilation.}{\v idPartComp}';
  1067.   end; (* procedure findDateAndCopyright *)
  1068.  
  1069. procedure interpretParameters;
  1070. (* interprets program parameters and parts of the configuration file *)
  1071.   var i,argVal: integer; s: string[79]; blanks: boolean;
  1072.   procedure copyParam(var dest: string; len: byte);
  1073.     begin dest:=copy(s,3+ord(s[3]=':'),len); end;
  1074.   procedure getArgVal;
  1075.     (* assigns value of argument, or $8000, to argVal *)
  1076.     var i: integer; st: string[9];
  1077.     begin
  1078.       copyParam(st,9);
  1079.       val(st,argVal,i);
  1080.       if i<>0 then argVal:=integer($8000);
  1081.     end; (* procedure getArgVal in interpretParameters *)
  1082.   function getBool: boolean;
  1083.     begin getBool:=(length(s)<3) OR (s[3]<>'-'); end;
  1084.   procedure setSize(var fs: string; dp: word);
  1085.     (* converts decipoints to an RTF halfpoint font size string *)
  1086.     begin
  1087.       str(dp DIV 5,fs);
  1088.       insert('\fs',fs,1);
  1089.     end; (* procedure setSize in interpretParameters *)
  1090.  
  1091.   begin
  1092.     blanks:=true;
  1093.     (* first, check configuration file *)
  1094.     profileString('OPTIONS','build',buildExpr,pred(sizeOf(buildExpr)));
  1095.     profileString('OPTIONS','compression',compression,pred(sizeOf(compression)));
  1096.     profileString('OPTIONS','filterFile',filterFileName,pred(sizeOf(filterFileName)));
  1097.     profileBoolean('OPTIONS','singlesInMain',singlesInMain);
  1098.     profileBoolean('OPTIONS','twoIndexes',twoIndexes);
  1099.     profileBoolean('OPTIONS','errorLog',errorLog);
  1100.     profileBoolean('OPTIONS','indexHeaders',indexHeaders);
  1101.     profileInt('OPTIONS','indexColumns',indexColumns);
  1102.     profileBoolean('OPTIONS','markKeys',markKeys);
  1103.     profileBoolean('OPTIONS','equalBlanks',blanks);
  1104.     profileInt('OPTIONS','releaseNo',releaseNo);
  1105.     profileBoolean('OPTIONS','scrollIndexTitle',scrollIndexTitle);
  1106.     profileBoolean('OPTIONS','tableWindow',tableWindow);
  1107.     profileBoolean('OPTIONS','expandedIndex',expandedIndex);
  1108.     (* second, check parameters *)
  1109.     for i:=1 to paramCount do begin
  1110.       s:=paramStr(i);
  1111.       case s[1] of
  1112.     '/','-': begin
  1113.       if length(s)=1 then errorExit(
  1114.         'Missing option after "'+s+'"',1);
  1115.       case upcase(s[2]) of
  1116.         'B': copyParam(buildExpr,pred(sizeOf(buildExpr)));
  1117.         (* legal: any .HPJ [OPTIONS] build= expression *)
  1118.         'C': begin
  1119.           copyParam(compression,pred(sizeOf(compression)));
  1120.         (* legal: 0, 1, no, yes, low, medium, high. Not checked *)
  1121.           if compression='' then compression:='YES';
  1122.         (* default if "-c" or "-c:" is specified *)
  1123.         end; (* case 'C' *)
  1124.         'F': begin
  1125.           copyParam(filterFileName,pred(sizeOf(filterFileName)));
  1126.           if filterFileName='' then errorExit(
  1127.         'No filter file name specified after "'+s+'"',1);
  1128.           filtered:=true;
  1129.         end; (* case 'F' *)
  1130.         '1': singlesInMain:=getBool;
  1131.         '2': twoIndexes:=getBool;
  1132.         'E': errorLog:=getBool;
  1133.         'H': indexHeaders:=getBool;
  1134.         'I': begin getArgVal; indexColumns:=argVal; end;
  1135.         'M': markKeys:=getBool;
  1136.         'Q': blanks:=getBool;
  1137.         'R': begin getArgVal; releaseNo:=argVal; end;
  1138.         'S': scrollIndexTitle:=getBool;
  1139.         'T': tableWindow:=getBool;
  1140.         'X': expandedIndex:=getBool;
  1141.         else errorExit('Unknown option: '+s,1);
  1142.       end; (* case upcase(s[2] of *)
  1143.     end; (* case '/','-' *)
  1144.     else begin
  1145.       if InPath='' then InPath:=s
  1146.       else if OutPath='' then OutPath:=s
  1147.       else errorExit('Too many parameters: '+s,1);
  1148.     end; (* case else *)
  1149.       end; (* case s[1] of *)
  1150.     end; (* for i:=1 *)
  1151.     (* if file paths were not program parameters, try configuration file *)
  1152.     if InPath='' then profileString('FILES','InPath',InPath,pred(sizeOf(InPath)));
  1153.     if OutPath='' then profileString('FILES','OutPath',OutPath,pred(sizeOf(OutPath)));
  1154.     (* read windows settings from configuration file *)
  1155.     profileString('CONFIG','pos and size',windowsPosSize,pred(sizeOf(windowsPosSize)));
  1156.     profileString('CONFIG','secondary pos and size',
  1157.       secWindowsPosSize,pred(sizeOf(secWindowsPosSize)));
  1158.     profileString('CONFIG','background',windowsBackgr,pred(sizeOf(windowsBackgr)));
  1159.     profileString('CONFIG','header background',windowsHdrBackgr,pred(sizeOf(windowsHdrBackgr)));
  1160.     profileString('CONFIG','header font',headerFont,pred(sizeOf(headerFont)));
  1161.     profileString('CONFIG','text font',textFont,pred(sizeOf(textFont)));
  1162.     profileInt('CONFIG','deciPoints',integer(deciPoints));
  1163.     profileInt('CONFIG','header deciPoints',integer(headerDeciPoints));
  1164.     profileInt('CONFIG','header 2nd deciPoints',integer(header2ndDeciPoints));
  1165.     (* update other values *)
  1166.     indexRows:=16; (* in most cases *)
  1167.     indexPages:=1; (* in two cases *)
  1168.     case indexColumns of
  1169.       1: indexRows:=256;
  1170.       4: indexPages:=4;
  1171.       8: indexPages:=2;
  1172.       16: ; (* already ok *)
  1173.       else errorExit('Illegal index columns, only 1, 4, 8, or 16 accepted',1);
  1174.     end; (* case indexColumns of *)
  1175.     if NOT blanks then begin
  1176.       equStr[4]:='=';
  1177.       equStr[0]:=#4; (* equStr = ' Ax=' *)
  1178.       equBlanks:=0;
  1179.     end; (* if NOT blanks *)
  1180.     setSize(fontSize,deciPoints);
  1181.     setSize(headerSize,headerDeciPoints);
  1182.     setSize(header2ndSize,header2ndDeciPoints);
  1183.     filtered:=filterFileName<>'';
  1184.     if NOT indexHeaders then indentIndex:=nl;
  1185.     if releaseNo<41 then begin tables:=false; tableWindow:=false; end;
  1186.     if NOT tableWindow then begin mainW:=''; tableW:=''; end;
  1187.   end; (* procedure interpretParameters *)
  1188.  
  1189.   const
  1190.     windows: integer = 0;
  1191.  
  1192.   var
  1193.     ch: char;
  1194.  
  1195.   begin
  1196.     Intro;
  1197.     if (paramStr(1)='?') OR (paramStr(1)='-?') OR (paramStr(1)='/?')
  1198.       then Explain; (* and exit *)
  1199.  
  1200.     fSplit(paramStr(0),homeDir,currentDir,currentDir);
  1201.       (* works only with DOS 3.30+ - currentDir is used as a dummy *)
  1202.     currentDir:=fExpand('.');
  1203.     if length(currentDir)>3 then begin
  1204.       inc(currentDir[0]);
  1205.       currentDir[length(currentDir)]:='\';
  1206.     end; (* if length()... *)
  1207.     interpretParameters;
  1208.     initializeArrays;
  1209.     nextAliasPP:=@firstAliasP;
  1210.  
  1211.     if InPath='' then begin
  1212.       write('Source directory: ');
  1213.       readln(InPath);
  1214.     end; (* if InPath='' *)
  1215.     if InPath<>'' then begin
  1216.       ch:=InPath[length(InPath)];
  1217.       if (ch<>':') AND (ch<>'\') then
  1218.     begin inc(InPath[0]); InPath[length(InPath)]:='\'; end;
  1219.     end; (* if InPath<>'' *)
  1220.  
  1221.     if OutPath='' then begin
  1222.       write('Dest. directory (has to be created in advance) : ');
  1223.       readln(OutPath);
  1224.     end; (* if OutPath='' *)
  1225.     if OutPath<>'' then begin
  1226.       ch:=OutPath[length(OutPath)];
  1227.       if (ch<>':') AND (ch<>'\') then
  1228.     begin inc(OutPath[0]); OutPath[length(OutPath)]:='\'; end;
  1229.     end; (* if OutPath<>'' *)
  1230.  
  1231.     ProcessTime:=memL[$40:$6C]; { timer ticks since midnight }
  1232.     findDateAndCopyright;
  1233.     CreateHPJ;
  1234.  
  1235.     OpenRTF(IndexFile, 'INDEX.RTF');
  1236.     NewHlpPage(IndexFile, 'Contents:', 'CONTENTS','m:2', specialClassification);
  1237.  
  1238.     readCategoryKeys; (* reads also titles *)
  1239.     OpenRTF(IntFile,   'INT.RTF');
  1240.     OpenRTF(SubIntFile,'SUBINT.RTF');
  1241.     if tables then OpenRTF(TableFile,'TABLE.RTF');
  1242.  
  1243.     if twoIndexes then
  1244.       AddTopic(IndexFile, nl, 'Interrupt Index',
  1245.     '!IfThenElse(IsMark("Compressed_Index"), '
  1246.     +'`JumpId("","idInterrupts")'', `JumpId("","idIndex")'')')
  1247.     else AddTopic(IndexFile, nl, 'Interrupts', 'idInterrupts');
  1248.     if tables then AddTopic(IndexFile, nl, 'Tables', 'idTables');
  1249.     AddTopic(IndexFile, nl, 'FILELIST', '1');
  1250.     AddTopic(IndexFile, nl, 'INTERRUP.1ST File', 'id1st');
  1251.     if filtered then begin
  1252.       AddTopic(IndexFile, nl, 'Filter Method', 'idFlt_meth');
  1253.       AddTopic(IndexFile, nl, 'Filter File', 'idFlt_file');
  1254.     end; (* if filtered *)
  1255.  
  1256.     profileInt('WINDOWS','number',windows);
  1257.     processTopics(windows); (* insert Ports, Memory etc. in index *)
  1258.  
  1259.     Credits;
  1260.  
  1261.     if twoIndexes then begin
  1262.       NewHlpPage(IndexFile, 'Interrupt Index', 'idIndex','m:3', specialClassification);
  1263.       AddTopic(IndexFile, nl, 'Compress index',
  1264.     '!SaveMark("Compressed_Index");JumpId("","idInterrupts")');
  1265.       { the program adds all following entries }
  1266.     end; (* if twoIndexes *)
  1267.     NewHlpPage(IntFile, 'Interrupts', 'idInterrupts','m:4', specialClassification);
  1268.     if twoIndexes then begin
  1269.       AddTopic(IntFile, nl, 'Expand index','!IfThen(IsMark("Compressed_Index"),'
  1270.     +' `DeleteMark("Compressed_Index")'');JumpId("","idIndex")');
  1271.       OutLn(IntFile, '');
  1272.       if indexColumns>1 then setTabs(IntFile, succ(ord(indexColumns<=4))*8,
  1273.     deciPoints, pred(indexColumns));
  1274.     end; (* if twoIndexes *)
  1275.  
  1276.     if tables then NewHlpPage(TableFile, 'Tables\f1'+fontSize
  1277.       +'\par\par Tab# INT Func Title','idTables','m:5', invalidClassification);
  1278.       (* "Tab# INT Func Title" in normal text font and size *)
  1279.  
  1280.     profileList('ALIAS',aliasP); (* read [ALIAS] section from config. file *)
  1281.     getNextAlias(aliasP,aliasId,aliasString); (* get the first one (if any) *)
  1282.     profileList('TABLEALIAS',tableAliasP);
  1283.     getNextAlias(tableAliasP,tableAliasId,tableAliasString);
  1284.  
  1285.     (* process either "interrup.lst" or "interrup.a".."interrup.?" *)
  1286.     if NOT ProcessIntList('interrup.lst') then begin
  1287.       ch := 'a';
  1288.       while ProcessIntList('interrup.'+ch) do inc(ch);
  1289.     end; (* if NOT ProcessIntList() *)
  1290.  
  1291.     if aliasString<>'' then begin
  1292.       writeln(#7'Alias string not found:'#13#10+'  "',aliasString,'"');
  1293.       if aliasP<>NIL then
  1294.     wl('One or more alias strings not processed.');
  1295.     end; (* if aliasP<>NIL *)
  1296.     if tableAliasString<>'' then begin
  1297.       writeln(#7'Table alias string not found:'#13#10+'  "',
  1298.     tableAliasString,'"');
  1299.       if tableAliasP<>NIL then
  1300.     wl('One or more table alias strings not processed.');
  1301.     end; (* if tableAliasP<>NIL *)
  1302.  
  1303.     if indexColumns=1 then insertQueued
  1304.     else INTsToIndex;
  1305.  
  1306.     NewHlpPage(IndexFile, 'INTERRUP.1ST File', 'id1st','f:0', invalidClassification);
  1307.       { the program adds all following entries }
  1308.     ProcessFile('interrup.1st', 'INTERRUP.1ST File');
  1309.     if filtered then processFilter;
  1310.  
  1311.     closeRTF(IntFile);
  1312.     closeRTF(SubIntFile);
  1313.     if tables then closeRTF(TableFile);
  1314.  
  1315.     processPages(windows); (* process Ports, Memory etc. *)
  1316.  
  1317.     if firstAliasP<>NIL then begin
  1318.       writeln(HPJ,#13#10'[ALIAS]');
  1319.       processAliasList(firstAliasP);
  1320.     end; (* if (firstAliasP<>NIL)... *)
  1321.     closeRTF(IndexFile);
  1322.     close(HPJ);
  1323.     if missingTableCounter>=missingTableLimit then
  1324.       writeln(missingTableCounter,' missing tables encountered.');
  1325.     ProcessTime:=memL[$40:$6C]-ProcessTime;
  1326.     writeln('The processing took ',(ProcessTime*10+91) DIV 182,' seconds.');
  1327.       (* 18.2 clock ticks per second, rounded *)
  1328.   end.
  1329.