home *** CD-ROM | disk | FTP | other *** search
/ Hall of Fame / HallofFameCDROM.cdr / prpascal / thelp.lzh / THELP.PAS
Pascal/Delphi Source File  |  1986-05-28  |  33KB  |  866 lines

  1. PROGRAM THELP;
  2.  
  3. {$C-}
  4. {$K-}
  5.  
  6.  
  7. {VARIABLE SECTION FOR 'THELP'}
  8.  
  9. type
  10.   text80          = string[80];
  11.   RegType         = record
  12.                       ax,bx,cx,dx,bp,si,di,ds,es,flags:integer
  13.                     end;
  14.   HalfRegType     = record
  15.                       al,ah,bl,bh,cl,ch,dl,dh:byte
  16.                     end;
  17.   IntrType        = record
  18.                       ip,cs : integer
  19.                     end;
  20.  
  21. const
  22.   EntryChar       = 19;                { ALT 'R' }
  23.   Escape          = 0;
  24.   FirstRow        = 3;
  25.   FirstCol        = 11;
  26.   WindowWidth     = 60;
  27.   WindowLength    = 18;
  28.   Dr              = 3;
  29.   Mr              = 12;
  30.   Cr              = $0D;
  31.   UserInt         = $66;                  { ***HERE IT IS*** }
  32.                                           {if thelp will not work with your other
  33.                                            resident stuff, change this number to
  34.                                            a free interrupt}
  35.   KybdInt         = $16;
  36.   ProgSize : integer = $A000;             { approx. program size }
  37.  
  38.   Regs    : regtype = (ax:0;bx:0;cx:0;dx:0;bp:0;si:0;di:0;ds:0;es:0;flags:0);
  39.   SaveDS  :integer  = 0;
  40.  
  41. var
  42.   SaveReg    : RegType;
  43.   SaveHalf   : HalfRegType absolute SaveReg;
  44.   HalfReg    : HalfRegType absolute regs;
  45.   i,j,x,y    : integer;
  46.   CursorPos  : integer;
  47.   Selection  : integer;
  48.   savebuf    : array[1..windowwidth] of array[1..windowlength] of integer;
  49.  
  50.  
  51. { MISC. PROCEDURES AND FUNTIONS FOR THELP }
  52.  
  53. procedure Bright(line:text80);
  54. begin
  55.   textcolor(15);
  56.   write(line);
  57.   textcolor(7);
  58. end;
  59.  
  60. procedure PrintHeading;
  61. begin
  62.   bright('T');       write('URBO Pascal ');
  63.   bright('Help   ');  write('Ver 2.0');
  64. end;
  65.  
  66. procedure PrintMCS;
  67. begin
  68.   bright('M'); write('agnum ');
  69.   bright('C'); write('ustom ');
  70.   bright('S'); write('oftware');
  71. end;
  72.  
  73. procedure Border;
  74. begin
  75.    GotoXY(1,1);                              {clear the window now}
  76.    Write(chr(218));
  77.    for i:=2 to windowwidth-1 do Write(chr(196));
  78.    Write(chr(191));
  79.    for i:=2 to windowlength-1 do
  80.    begin
  81.       GotoXY(1, i);  Write(chr(179));
  82.       for j := 2 to windowwidth-1 do
  83.          Write(' ');
  84.       GotoXY(windowwidth, i);  Write(chr(179));
  85.    end;
  86.    GotoXY(1, windowlength);
  87.    Write(chr(192));
  88.    for i:=2 to windowwidth-1 do Write(chr(196));
  89.    Write(chr(217));
  90. END;
  91.  
  92. function GetScreenChar:integer;
  93. begin
  94.    savereg.ax := $0800;                 {9 -> get character/attr @ cursor}
  95.    savereg.bx := 0;
  96.    Intr($10,savereg);
  97.    GetScreenChar := savereg.ax
  98. end;
  99.  
  100. procedure PutScreenChar(input:integer);
  101. begin
  102.    savereg.ax := $0900 + (input and $FF); {a -> put character/attr @ cursor}
  103.    savereg.bx := input shr 8;          {put the attrib in bl and 0 in bh}
  104.    savereg.cx := 1;
  105.    Intr($10,savereg)
  106. end;
  107.  
  108. procedure OpenWindow;
  109. begin
  110.   window (firstcol, firstrow, firstcol+windowwidth, firstrow+windowlength);
  111.     for j := 1 to windowlength do
  112.       for i := 1 to windowwidth do
  113.       begin
  114.          GoToXY(i,j);
  115.          savebuf[i][j] := GetScreenChar      {get a attribute/character at the cursor}
  116.       end;
  117.    border;
  118.   window (firstcol+1,firstrow+1,firstcol+windowwidth-2,firstrow+windowlength-2);
  119.   gotoxy(1,1);
  120. end;
  121.  
  122. procedure closewindow;
  123. begin
  124.   window (firstcol, firstrow, firstcol+windowwidth, firstrow+windowlength);
  125.   for j := 1 to windowlength do
  126.     for i := 1 to windowwidth do
  127.       begin
  128.          GoToXY(i,j);
  129.          PutScreenChar(savebuf[i][j])
  130.       end
  131. end;
  132.  
  133.  
  134. { MENU PRINT PROCEDURES FOR THELP }
  135.  
  136. procedure PrintMenu(number:integer);
  137. begin
  138.   case number of
  139.     0  : begin
  140.            gotoxy(mr+3,2);   PrintHeading;
  141.            gotoxy(mr+7,3);   PrintMCS;
  142.            gotoxy(mr+12,5);  write('MAIN MENU');
  143.            gotoxy(mr,6);   write('<1> Edit Commands');
  144.            gotoxy(mr,7);   write('<2> Syntax Structure');
  145.            gotoxy(mr,8);   write('<3> Standard Procedures/Functions');
  146.            gotoxy(mr,9);   write('<4> Compiler Directives');
  147.            gotoxy(mr,10);  write('<5> Runtime Errors');
  148.            gotoxy(mr,11);  write('<6> I/O Errors');
  149.            gotoxy(mr,12);  write('<7> Standard Identifiers');
  150.            gotoxy(mr,13);  write('<8> Version 2 Additions Part I');
  151.            gotoxy(mr,14);  write('<9> Version 2 Additions Part II');
  152.          end;
  153.     1  : begin
  154.            gotoxy(mr+3,2);   PrintHeading;
  155.            gotoxy(mr+7,3);   PrintMCS;
  156.            gotoxy(mr+7,5);   write('EDITOR COMMANDS MENU');
  157.            gotoxy(mr,7);   write('<1> Cursor Movements Part I');
  158.            gotoxy(mr,8);   write('<2> Cursor Movements Part II');
  159.            gotoxy(mr,9);   write('<3> Insert and Delete Commands');
  160.            gotoxy(mr,10);  write('<4> Block Commands');
  161.            gotoxy(mr,11);  write('<5> Miscellaneous and Options');
  162.          end;
  163.  
  164.     2  : begin
  165.            gotoxy(mr+3,2);   PrintHeading;
  166.            gotoxy(mr+7,3);   PrintMCS;
  167.            gotoxy(mr+6,5);   write('SYNTAX STRUCTURE MENU');
  168.            gotoxy(mr,6);   write('<1> TYPE');
  169.            gotoxy(mr,7);   write('<2> CONST');
  170.            gotoxy(mr,8);   write('<3> VAR');
  171.            gotoxy(mr,9);   write('<4> WITH DO and CASE');
  172.            gotoxy(mr,10);  write('<5> REPEAT UNTIL and WHILE DO');
  173.            gotoxy(mr,11);  write('<6> IF THEN ELSE and FOR TO DO');
  174.            gotoxy(mr,12);  write('<7> PROGRAM, PROCEDURE and FUNCTION');
  175.            gotoxy(mr,13);  write('<8> Program Structure');
  176.          end;
  177.  
  178.     3  : begin
  179.            gotoxy(mr+3,2);   PrintHeading;
  180.            gotoxy(mr+7,3);   PrintMCS;
  181.            gotoxy(mr,5);   write('STANDARD PROCEDURES/FUNCTIONS MENU');
  182.            gotoxy(mr,6);   write('<1> Input/Output Procedures');
  183.            gotoxy(mr,7);   write('<2> Arithmetic Functions');
  184.            gotoxy(mr,8);   write('<3> Scalar Functions/Heap Control');
  185.            gotoxy(mr,9);   write('<4> String Procedures and Functions');
  186.            gotoxy(mr,10);  write('<5> File Handling Procedures');
  187.            gotoxy(mr,11);  write('<6> File Handling Functions');
  188.            gotoxy(mr,12);  write('<7> Transfer/Screen Procs & Funcs');
  189.            gotoxy(mr,13);  write('<8> Miscellaneous Proc/Func Part I');
  190.            gotoxy(mr,14);  write('<9> Miscellaneous Functions Part II');
  191.          end;
  192.   end;
  193.   repeat
  194.     gotoxy(19,15);  write('Enter Selection  ? ');
  195.     savereg.ax := $00;
  196.     Intr(userint,savereg);
  197.     selection := savehalf.ah - 1;
  198.   until ((selection in [0..9]) and (number in [0,3]))
  199.      or ((selection in [0..5]) and (number = 1))
  200.      or ((selection in [0..8]) and (number = 2));
  201.   clrscr;
  202. end;
  203.  
  204.  
  205. procedure Wait;
  206. begin
  207.   gotoxy(14,16); write('PRESS <ESC> TO RETURN TO MENU');
  208.   repeat
  209.     savereg.ax := 0;
  210.     Intr(userint,savereg);
  211.   until savehalf.ah = $01;
  212.   clrscr;
  213. end;
  214.  
  215. procedure CursorMoveI;
  216. begin
  217.   gotoxy(dr,2);   write('CURSOR MOVEMENTS  Part I :');
  218.   gotoxy(dr,4);   write('  Character left         Ctrl-S  ->   ',#$1B);
  219.   gotoxy(dr,5);   write('    Alternative          Ctrl-H  ->  ');
  220.   gotoxy(dr,6);   write('  Character right        Ctrl-D  ->   ',#$1A);
  221.   gotoxy(dr,7);   write('  Word left              Ctrl-A  ->  Ctrl ',#$1B);
  222.   gotoxy(dr,8);   write('  Word right             Ctrl-F  ->  Ctrl ',#$1A);
  223.   gotoxy(dr,9);   write('  Line up                Ctrl-E  ->   ',#$18);
  224.   gotoxy(dr,10);  write('  Line down              Ctrl-X  ->   ',#$19);
  225.   gotoxy(dr,11);  write('  Scroll up              Ctrl-W  ->  ');
  226.   gotoxy(dr,12);  write('  Scroll down            Ctrl-Z  ->  ');
  227.   gotoxy(dr,13);  write('  Page up                Ctrl-R  ->  PgUp');
  228.   gotoxy(dr,14);  write('  Page down              Ctrl-C  ->  PgDn');
  229.   Wait;
  230. end;
  231.  
  232. procedure CursorMoveII;
  233. begin
  234.   gotoxy(dr,2);   write('CURSOR MOVEMENTS  Part II :');
  235.   gotoxy(dr,4);   write('  To left on line      Ctrl-Q Ctrl-S  ->  Home');
  236.   gotoxy(dr,5);   write('  To right on line     Ctrl-Q Ctrl-D  ->  End');
  237.   gotoxy(dr,6);   write('  To top of page       Ctrl-Q Ctrl-E  ->  Ctrl Home');
  238.   gotoxy(dr,7);   write('  To bottom of page    Ctrl-Q Ctrl-X  ->  Ctrl End');
  239.   gotoxy(dr,8);   write('  To top of file       Ctrl-Q Ctrl-R  ->  Ctrl PgUp');
  240.   gotoxy(dr,9);   write('  To end of file       Ctrl-Q Ctrl-C  ->  Ctrl PgDn');
  241.   gotoxy(dr,10);  write('  To top of block      Ctrl-Q Ctrl-B  ->  ');
  242.   gotoxy(dr,11);  write('  To end of block      Ctrl-Q Ctrl-K  ->  ');
  243.   gotoxy(dr,12);  write('  To last cur.pos.     Ctrl-Q Ctrl-P  ->  ');
  244.   Wait;
  245. end;
  246.  
  247. procedure InsertDelete;
  248. begin
  249.   gotoxy(dr,2);   write('INSERT and DELETE :');
  250.   gotoxy(dr,4);   write('  Insert mode on/off     Ctrl-V         ->  Ins');
  251.   gotoxy(dr,5);   write('  Insert line            Ctrl-N         ->  ');
  252.   gotoxy(dr,6);   write('  Delete line            Ctrl-Y         ->  ');
  253.   gotoxy(dr,7);   write('  Del to end of line     Ctrl-Q Ctrl-Y  ->  ');
  254.   gotoxy(dr,8);   write('  Delete right word      Ctrl-T         ->  ');
  255.   gotoxy(dr,9);   write('  Del char under cursor  Ctrl-G         ->  Del');
  256.   gotoxy(dr,10);  write('  Delete left character  <DEL>          ->  ');
  257.   gotoxy(dr,11);  write('    Alternative          nothing        ->  ');
  258.   Wait;
  259. end;
  260.  
  261. procedure BlockCommands;
  262. begin
  263.   gotoxy(dr,2);   write('BLOCK COMMANDS :');
  264.   gotoxy(dr,4);   write('  Mark block begin       Ctrl-K Ctrl-B  ->  F7');
  265.   gotoxy(dr,5);   write('  Mark block end         Ctrl-K Ctrl-K  ->  F8');
  266.   gotoxy(dr,6);   write('  Mark single word       Ctrl-K Ctrl-T  ->  ');
  267.   gotoxy(dr,7);   write('  Hide/display block     Ctrl-K Ctrl-H  ->  ');
  268.   gotoxy(dr,8);   write('  Copy block             Ctrl-K Ctrl-C  ->  ');
  269.   gotoxy(dr,9);   write('  Move block             Ctrl-K Ctrl-V  ->  ');
  270.   gotoxy(dr,10);  write('  Delete block           Ctrl-K Ctrl-Y  ->  ');
  271.   gotoxy(dr,11);  write('  Read block from disk   Ctrl-K Ctrl-R  ->  ');
  272.   gotoxy(dr,12);  write('  Write block to disk    Ctrl-K Ctrl-W  ->  ');
  273.   Wait;
  274. end;
  275.  
  276. procedure MiscEditing;
  277. begin
  278.   gotoxy(dr,1);   write('MISC. EDITING COMMANDS :');
  279.   gotoxy(dr,2);   write('  End edit               Ctrl-K Ctrl-D  ->  ');
  280.   gotoxy(dr,3);   write('  Tab                    Ctrl-I         ->  Tab');
  281.   gotoxy(dr,4);   write('  Auto tab on/off        Ctrl-Q Ctrl-I  ->  ');
  282.   gotoxy(dr,5);   write('  Restore line           Ctrl-Q Ctrl-L  ->  ');
  283.   gotoxy(dr,6);   write('  Find                   Ctrl-Q Ctrl-F  ->  ');
  284.   gotoxy(dr,7);   write('  Find and Replace       Ctrl-Q Ctrl-A  ->  ');
  285.   gotoxy(dr,8);   write('  Repeat last find       Ctrl-L         ->  ');
  286.   gotoxy(dr,9);   write('  Control char prefix    Ctrl-P         ->  ');
  287.   gotoxy(dr,10);  write('  Abort operation        Ctrl-U         ->  ');
  288.   gotoxy(dr,11);  write('OPTIONS :');
  289.   gotoxy(dr,12);  write('  B - Backwards        U - Ignore upper/lowercase');
  290.   gotoxy(dr,13);  write('  G - Global           W - Whole words only');
  291.   gotoxy(dr,14);  write('  N - No qestions      n - Number of occurences');
  292.   Wait;
  293. end;
  294.  
  295. procedure PrintType;
  296. begin
  297.   gotoxy(dr,2);   write('{ integer, real, boolean, char, string[xx] }');
  298.   gotoxy(dr,4);   write('TYPE');
  299.   gotoxy(dr,5);   write('  text80   = STRING[80];');
  300.   gotoxy(dr,6);   write('  letter   = ''a''..''z'';');
  301.   gotoxy(dr,7);   write('  tones    = 1..12;');
  302.   gotoxy(dr,8);   write('  row      = SET OF tones;');
  303.   gotoxy(dr,9);   write('  chtype   = char;');
  304.   gotoxy(dr,10);  write('  regtype  = record');
  305.   gotoxy(dr,11);  write('               ax,bx,cx,dx,bp,si,di,ds,es,flags:INTEGER');
  306.   gotoxy(dr,12);  write('             end;');
  307.   gotoxy(dr,13);  write('  day      = (monday,tuesday,wenesday,thursday,');
  308.   gotoxy(dr,14);  write('              friday,saturday,sunday);');
  309.   Wait;
  310. end;
  311.  
  312. procedure PrintConst;
  313. begin
  314.   gotoxy(dr,2);   write('{ stored in code_segment }');
  315.   gotoxy(dr,3);   write('{ integer, real, boolean, char, string[xx] }');
  316.   gotoxy(dr,5);   write('CONST');
  317.   gotoxy(dr,6);   write('  minus2     = -2;');
  318.   gotoxy(dr,7);   write('  pagesize   = 60;');
  319.   gotoxy(dr,8);   write('  pi         = 3.1415926535;');
  320.   gotoxy(dr,9);   write('  histring   = ''hello'';');
  321.   gotoxy(dr,10);  write('  valid      = TRUE;');
  322.   gotoxy(dr,11);  write('  msb : BYTE = 0;');
  323.   gotoxy(dr,12);  write('  lsb : BYTE = 0;');
  324.   Wait;
  325. end;
  326.  
  327. procedure PrintVar;
  328. begin
  329.   gotoxy(dr,2);   write('{ stored in data_segment }');
  330.   gotoxy(dr,3);   write('{ integer, real, boolean, char, string[xx] }');
  331.   gotoxy(dr,4);   write('VAR');
  332.   gotoxy(dr,5);   write('  count,index    : INTEGER;');
  333.   gotoxy(dr,6);   write('  result,value   : REAL;');
  334.   gotoxy(dr,7);   write('  eom,character  : CHAR;');
  335.   gotoxy(dr,8);   write('  line           : STRING[80];');
  336.   gotoxy(dr,9);   write('  error          : BOOLEAN;');
  337.   gotoxy(dr,10);  write('  inventory      : FILE OF invtype;');
  338.   gotoxy(dr,11);  write('  matrix         : ARRAY [1..50,1..50] OF INTEGER;');
  339.   gotoxy(dr,12);  write('  cmdlength      : BYTE ABSOLUTE CSEG:$0080;');
  340.   gotoxy(dr,13);  write('  cmdline        : STRING[127] ABSOLUTE CSEG:$0080;');
  341.   gotoxy(dr,14);  write('  intrip         : INTEGER ABSOLUTE $0000:$0040;');
  342.   Wait;
  343. end;
  344.  
  345. procedure PrintCase;
  346. begin
  347.   gotoxy(dr,2);   write('WITH record_identifier DO');
  348.   gotoxy(dr,3);   write('  statement;');
  349.   gotoxy(dr,6);   write('CASE expression OF');
  350.   gotoxy(dr,7);   write('  constant  :  statement;');
  351.   gotoxy(dr,8);   write('  constant  :  statement');
  352.   gotoxy(dr,9);   write('ELSE');
  353.   gotoxy(dr,10);  write('  statement;');
  354.   gotoxy(dr,11);  write('  statement');
  355.   gotoxy(dr,12);  write('END;');
  356.   Wait;
  357. end;
  358.  
  359. procedure RepeatWhile;
  360. begin
  361.   gotoxy(dr,4);   write('REPEAT');
  362.   gotoxy(dr,5);   write('  statement;');
  363.   gotoxy(dr,6);   write('  statement ');
  364.   gotoxy(dr,7);   write('UNTIL condition;');
  365.   gotoxy(dr,10);  write('WHILE condition DO');
  366.   gotoxy(dr,11);  write('  statement;');
  367.   Wait;
  368. end;
  369.  
  370. procedure IfFor;
  371. begin
  372.   gotoxy(dr,2);   write('IF condition');
  373.   gotoxy(dr,3);   write('  THEN statement');
  374.   gotoxy(dr,4);   write('  ELSE statement;');
  375.   gotoxy(dr,7);   write('FOR variable := expression1 TO expression2 DO');
  376.   gotoxy(dr,8);   write('  statement;');
  377.   gotoxy(dr,10);  write('                      or');
  378.   gotoxy(dr,12);  write('FOR variable := expression1 DOWNTO expression2 DO');
  379.   gotoxy(dr,13);  write('  statement;');
  380.   Wait;
  381. end;
  382.  
  383. procedure ProgProcFunc;
  384. begin
  385.   gotoxy(dr,4);   write('PROGRAM progname;');
  386.   gotoxy(dr,7);   write('PROCEDURE procname(VAR num1,num2 : INTEGER; ch : CHAR);');
  387.   gotoxy(dr,8);   write('PROCEDURE procname(str1 : STRING80; length : REAL);');
  388.   gotoxy(dr,11);  write('FUNCTION funcname(VAR value : REAL) : INTEGER;');
  389.   gotoxy(dr,12);  write('FUNCTION funcname(ch : CHAR; num : INTEGER) : STRING80;');
  390.   Wait;
  391. end;
  392.  
  393. procedure ProgramStructure;
  394. begin
  395.   gotoxy(dr,1);   write('PROGRAM programname;');
  396.   gotoxy(dr,2);   write('type');
  397.   gotoxy(dr,3);   write('  .....');
  398.   gotoxy(dr,4);   write('const');
  399.   gotoxy(dr,5);   write('  .....');
  400.   gotoxy(dr,6);   write('var');
  401.   gotoxy(dr,7);   write('  .....');
  402.   gotoxy(dr,8);   write('PROCEDURE procedurename(variable_list);');
  403.   gotoxy(dr,9);   write('  .....');
  404.   gotoxy(dr,10);  write('FUNCTION functionname(variable_list):type_identifier;');
  405.   gotoxy(dr,11);  write('  .....');
  406.   gotoxy(dr,12);  write('begin');
  407.   gotoxy(dr,13);  write('  .....');
  408.   gotoxy(dr,14);  write('end.');
  409.   Wait;
  410. end;
  411.  
  412. procedure InputOutput;
  413. begin
  414.   gotoxy(dr,1);   write('INPUT/OUTPUT PROCEDURES :');
  415.   gotoxy(dr,2);   write('  Read(var F:file of type;var v:type);');
  416.   gotoxy(dr,3);   write('  Read(var F:text;var I:Integer);');
  417.   gotoxy(dr,4);   write('  Read(var F:text;var R:Real);');
  418.   gotoxy(dr,5);   write('  Read(var F:text;var C:Char);');
  419.   gotoxy(dr,6);   write('  Read(var F:text;var S:string);');
  420.   gotoxy(dr,7);   write('  Readln(var F:text);');
  421.   gotoxy(dr,8);   write('  Write(var F:file of type;var v:type);');
  422.   gotoxy(dr,9);   write('  Write(var F:text;I:Integer);');
  423.   gotoxy(dr,10);  write('  Write(var F:text;R:Real);');
  424.   gotoxy(dr,11);  write('  Write(var F:text;B:Boolean);');
  425.   gotoxy(dr,12);  write('  Write(var F:text;C:Char);');
  426.   gotoxy(dr,13);  write('  Write(var F:text;S:string);');
  427.   gotoxy(dr,14);  write('  Writeln(var F:text);');
  428.   Wait;
  429. end;
  430.  
  431. procedure Arithmetic;
  432. begin
  433.   gotoxy(dr,2);   write('ARITHMETIC FUNCTIONS :');
  434.   gotoxy(dr,3);   write('  Abs(I:Integer):Integer;');
  435.   gotoxy(dr,4);   write('  Abs(R:Real):Real;');
  436.   gotoxy(dr,5);   write('  ArcTan(R:Real):Real;');
  437.   gotoxy(dr,6);   write('  Cos(R:Real):Real;');
  438.   gotoxy(dr,7);   write('  Exp(R:Real):Real;');
  439.   gotoxy(dr,8);   write('  Frac(R:Real):Real;');
  440.   gotoxy(dr,9);   write('  Int(R:Real):Real;');
  441.   gotoxy(dr,10);  write('  Ln(R:Real):Real;');
  442.   gotoxy(dr,11);  write('  Sin(R:Real):Real;');
  443.   gotoxy(dr,12);  write('  Sqr(I:Integer):Integer;');
  444.   gotoxy(dr,13);  write('  Sqr(R:Real):Real;');
  445.   gotoxy(dr,14);  write('  Sqrt(R:Real):Real;');
  446.   Wait;
  447. end;
  448.  
  449. procedure ScalarHeap;
  450. begin
  451.   gotoxy(dr,2);   write('SCALAR FUNCTIONS :');
  452.   gotoxy(dr,3);   write('  Odd(I:Integer):Boolean;');
  453.   gotoxy(dr,4);   write('  Pred(X:scalar):scalar;');
  454.   gotoxy(dr,5);   write('  Succ(X:scalar):scalar;');
  455.   gotoxy(dr,6);   write('HEAP CONTROL PROCEDURES :');
  456.   gotoxy(dr,7);   write('  GetMem(var P:pointer;I:Integer);');
  457.   gotoxy(dr,8);   write('  Mark(var P:pointer);');
  458.   gotoxy(dr,9);   write('  New(var P:pointer);');
  459.   gotoxy(dr,10);  write('  Release(var P:pointer);');
  460.   gotoxy(dr,11);  write('HEAP CONTROL FUNCTIONS :');
  461.   gotoxy(dr,12);  write('  MemAvail:Integer;');
  462.   gotoxy(dr,13);  write('  Ord(P:pointer):Integer;');
  463.   gotoxy(dr,14);  write('  Ptr(I:Integer):pointer;');
  464.   Wait;
  465. end;
  466.  
  467. procedure Strings;
  468. begin
  469.   gotoxy(dr,2);   write('STRING PROCEDURES :');
  470.   gotoxy(dr,3);   write('  Delete(var S:string;Pos,Len:Integer);');
  471.   gotoxy(dr,4);   write('  Insert(S:string;var D:string;Pos:Integer);');
  472.   gotoxy(dr,5);   write('  Str(I:Integer;var S:string);');
  473.   gotoxy(dr,6);   write('  Str(R:Real;var S:string);');
  474.   gotoxy(dr,7);   write('  Val(S:string;var R:Real;var p:Integer);');
  475.   gotoxy(dr,8);   write('  Val(S:string;var I,P:Integer);');
  476.   gotoxy(dr,9);   write('STRING FUNCTIONS :');
  477.   gotoxy(dr,10);  write('  Concat(S1,S2,...,Sn:string):string;');
  478.   gotoxy(dr,11);  write('  Copy(S:string;Pos,Len:Integer):string;');
  479.   gotoxy(dr,12);  write('  Length(S:string):Integer;');
  480.   gotoxy(dr,13);  write('  Pos(Pattern,Source:string):Integer;');
  481.   Wait;
  482. end;
  483.  
  484. procedure FileProc;
  485. begin
  486.   gotoxy(dr,2);   write('FILE PROCEDURES :');
  487.   gotoxy(dr,3);   write('  Assign(var F:file;name:string);');
  488.   gotoxy(dr,4);   write('  BlockRead(var F:file;var Dest:Type;Num:Integer);');
  489.   gotoxy(dr,5);   write('  BlockWrite(var F:file;var Dest:Type;Num:Integer);');
  490.   gotoxy(dr,6);   write('  Chain(var F:file);');
  491.   gotoxy(dr,7);   write('  Close(var F:file);');
  492.   gotoxy(dr,8);   write('  Erase(var F:file);');
  493.   gotoxy(dr,9);   write('  Execute(var F:file);');
  494.   gotoxy(dr,10);  write('  Rename(var F:file;Name:string);');
  495.   gotoxy(dr,11);  write('  Reset(var F:file);');
  496.   gotoxy(dr,12);  write('  Rewrite(var F:file);');
  497.   gotoxy(dr,13);  write('  Seek(var F:file of type;Pos:Integer);');
  498.   Wait;
  499. end;
  500.  
  501. procedure FileFunc;
  502. begin
  503.   gotoxy(dr,2);   write('FILE FUNCTIONS :');
  504.   gotoxy(dr,3);   write('  Eof(var F:file):Boolean;');
  505.   gotoxy(dr,4);   write('  Eoln(var F:Text):Boolean;');
  506.   gotoxy(dr,5);   write('  FilePos(var F:file of type):Integer;');
  507.   gotoxy(dr,6);   write('  FilePos(var F:file):Integer;');
  508.   gotoxy(dr,7);   write('  FileSize(var F:file of type):Integer;');
  509.   gotoxy(dr,8);   write('  FileSize(var F:file):Integer;');
  510.   Wait;
  511. end;
  512.  
  513. procedure TransferScreen;
  514. begin
  515.   gotoxy(dr,1);   write('TRANSFER FUNCTIONS :');
  516.   gotoxy(dr,2);   write('  Chr(I:Integer):Char;');
  517.   gotoxy(dr,3);   write('  Ord(X:scalar):Integer;');
  518.   gotoxy(dr,4);   write('  Round(R:Real):Integer;');
  519.   gotoxy(dr,5);   write('  Trunc(R:Real):Integer;');
  520.   gotoxy(dr,6);   write('SCREEN RELATED PROCEDURES :');
  521.   gotoxy(dr,7);   write('  CrtExit;');
  522.   gotoxy(dr,8);   write('  CrtInit;');
  523.   gotoxy(dr,9);   write('  ClrEol;');
  524.   gotoxy(dr,10);  write('  ClrScr;');
  525.   gotoxy(dr,11);  write('  DelLine;');
  526.   gotoxy(dr,12);  write('  GotoXY(X,Y:Integer);');
  527.   gotoxy(dr,13);  write('  InsLine;');
  528.   gotoxy(dr,14);  write('  LowVideo;');
  529.   gotoxy(dr,15);  write('  NormVideo;');
  530.   Wait;
  531. end;
  532.  
  533. procedure MiscProc;
  534. begin
  535.   gotoxy(dr,1);   write('MISCELLANEOUS PROCEDURES :');
  536.   gotoxy(dr,2);   write('  Bdos(func,param:Integer);');
  537.   gotoxy(dr,3);   write('  Bios(func,param:Integer);');
  538.   gotoxy(dr,4);   write('  Delay(mS:Integer);');
  539.   gotoxy(dr,5);   write('  FillChar(var dest;length:Integer;data:Char);');
  540.   gotoxy(dr,6);   write('  FillChar(var dest;length:Integer;data:Byte);');
  541.   gotoxy(dr,7);   write('  Halt;');
  542.   gotoxy(dr,8);   write('  Move(var source,dest;length:Integer);');
  543.   gotoxy(dr,9);   write('  Randomize;');
  544.   gotoxy(dr,10);  write('  Inline($CD/$10);');
  545.   gotoxy(dr,11);  write('  Intr(intrnum:Integer;regs:Regtype);');
  546.   gotoxy(dr,12);  write('MISCELLANEOUS FUNCTIONS Part I :');
  547.   gotoxy(dr,13);  write('  Addr(var variable):Integer;');
  548.   gotoxy(dr,14);  write('  Addr(<function identifier>):Integer;');
  549.   gotoxy(dr,15);  write('  Addr(<procedure identifier>):Integer;');
  550.   Wait;
  551. end;
  552.  
  553. procedure MiscFunc;
  554. begin
  555.   gotoxy(dr,1);   write('MISCELLANEOUS FUNCTIONS Part II :');
  556.   gotoxy(dr,2);   write('  Bdos(Func,Param:Integer):Byte;');
  557.   gotoxy(dr,3);   write('  BdosHL(Func,Param:Integer):Integer;');
  558.   gotoxy(dr,4);   write('  Bios(Func,Param:Integer):Byte;');
  559.   gotoxy(dr,5);   write('  BiosHL(Func,Param:Integer):Integer');
  560.   gotoxy(dr,6);   write('  Hi(I:Integer):Integer;');
  561.   gotoxy(dr,7);   write('  IOresult:Boolean;');
  562.   gotoxy(dr,8);   write('  KeyPressed:Boolean;');
  563.   gotoxy(dr,9);   write('  Lo(I:Integer):Integer;');
  564.   gotoxy(dr,10);  write('  Random(Range:Integer):Integer;');
  565.   gotoxy(dr,11);  write('  Random:Real;');
  566.   gotoxy(dr,12);  write('  SizeOf(var variable):Integer;');
  567.   gotoxy(dr,13);  write('  SizeOf(<type identifier>):Integer;');
  568.   gotoxy(dr,14);  write('  Swap(I:Integer):Integer;');
  569.   gotoxy(dr,15);  write('  Upcase(Ch:Char):Char;');
  570.   Wait;
  571. end;
  572.  
  573. procedure PrintDirectives;
  574. begin
  575.   gotoxy(dr,1);   write('COMPILER DIRECTIVES :');
  576.   gotoxy(dr,2);   write('  B - I/O Mode Selection          [ default B+ ]');
  577.   gotoxy(dr,3);   write('  C - CNTL S and CNTL C           [ default C+ ]');
  578.   gotoxy(dr,4);   write('  I - I/O Error Handling          [ default I+ ]');
  579.   gotoxy(dr,5);   write('  I - Include Files');
  580.   gotoxy(dr,6);   write('  R - Index Range Check           [ default R- ]');
  581.   gotoxy(dr,7);   write('  V - Var-parameter Type Checking [ default V+ ]');
  582.   gotoxy(dr,8);   write('  U - User Interupt               [ default U- ]');
  583.   gotoxy(dr,9);   write('  K - Stack Checking              [ default K+ ]');
  584.   gotoxy(dr,10);  write('  examples  :');
  585.   gotoxy(dr,11);  write('    {$I-}');
  586.   gotoxy(dr,12);  write('    {$I INCLUDE.FIL}');
  587.   gotoxy(dr,13);  write('    {$B-,R+,V-}');
  588.   gotoxy(dr,14);  write('    (*$U+*)');
  589.   Wait;
  590. end;
  591.  
  592. procedure RuntimeErrors;
  593. begin
  594.   gotoxy(dr,2);   write('RUN-TIME ERROR MESSAGES :');
  595.   gotoxy(dr,3);   write('  01  -  Floating point overflow.');
  596.   gotoxy(dr,4);   write('  02  -  Division by zero attempted.');
  597.   gotoxy(dr,5);   write('  03  -  Sqrt argument error.');
  598.   gotoxy(dr,6);   write('  04  -  Ln argument error.');
  599.   gotoxy(dr,7);   write('  10  -  String length error.');
  600.   gotoxy(dr,8);   write('  11  -  Invalid string index.');
  601.   gotoxy(dr,9);   write('  90  -  Index out of range.');
  602.   gotoxy(dr,10);  write('  91  -  Scalar or subrange out of range.');
  603.   gotoxy(dr,11);  write('  92  -  Out of integer range.');
  604.   gotoxy(dr,12);  write('  FF  -  Heap/stack collision.');
  605.   Wait;
  606. end;
  607.  
  608. procedure IOErrors;
  609. begin
  610.   gotoxy(dr,1);   write('I/O ERROR MESSAGES :');
  611.   gotoxy(dr,2);   write('  01  -  File does not exist.');
  612.   gotoxy(dr,3);   write('  02  -  File not open for input.');
  613.   gotoxy(dr,4);   write('  03  -  File not open for output.');
  614.   gotoxy(dr,5);   write('  04  -  File not open.');
  615.   gotoxy(dr,6);   write('  10  -  Error in numeric format.');
  616.   gotoxy(dr,7);   write('  20  -  Operation not allowed on a logical device.');
  617.   gotoxy(dr,8);   write('  21  -  Not allowed in direct mode.');
  618.   gotoxy(dr,9);   write('  22  -  Assign to std files not allowed.');
  619.   gotoxy(dr,10);  write('  90  -  Record length mismatch.');
  620.   gotoxy(dr,11);  write('  91  -  Seek beyond end-of-file.');
  621.   gotoxy(dr,12);  write('  99  -  Unexpected end-of-file.');
  622.   gotoxy(dr,13);  write('  F0  -  Disk write error.');
  623.   gotoxy(dr,14);  write('  F1  -  Directory is full.');
  624.   gotoxy(dr,15);  write('  F2  -  File size overflow.   FF  -  File disappeared.');
  625.   Wait;
  626. end;
  627.  
  628. procedure StdIdentifiers;
  629. begin
  630.   gotoxy(dr,2);   write('STANDARD IDENTIFIERS :');
  631.   gotoxy(dr,3);   write('  DSeg:Integer');
  632.   gotoxy(dr,4);   write('  CSeg:Integer');
  633.   gotoxy(dr,5);   write('  SSeg:Integer');
  634.   gotoxy(dr,6);   write('  Seg(Name):Integer');
  635.   gotoxy(dr,7);   write('  Addr(Name):pointer');
  636.   gotoxy(dr,8);   write('  Ofs(Name):Integer');
  637.   gotoxy(dr,9);   write('  Mem[segment:offset]');
  638.   gotoxy(dr,10);  write('  MemW[segment:offset]');
  639.   gotoxy(dr,11);  write('  Port[portnum]');
  640.   gotoxy(dr,12);  write('  PortW[portnum]');
  641.   gotoxy(dr,13);  write('  LongFilePos       LongFileSize');
  642.   gotoxy(dr,14);  write('  LongSeek          MsDos');
  643.   Wait;
  644. end;
  645.  
  646. procedure Version2I;
  647. begin
  648.   gotoxy(dr,2);   write('VERSION 2 Part I ');
  649.   gotoxy(dr,3);   write('  Procedures Part I :');
  650.   gotoxy(dr,4);   write('    Dispose(var P:pointer);');
  651.   gotoxy(dr,5);   write('    Draw(X1,Y1,X2,Y2,Color:Integer);');
  652.   gotoxy(dr,6);   write('    FreeMem(var P:pointer,I:Integer);');
  653.   gotoxy(dr,7);   write('    GraphBackground(Color:Integer);');
  654.   gotoxy(dr,8);   write('    GraphColorMode;');
  655.   gotoxy(dr,9);   write('    GraphMode;');
  656.   gotoxy(dr,10);  write('    GraphWindow(X1,Y1,X2,Y2,Color:Integer);');
  657.   gotoxy(dr,11);  write('    HiRes;');
  658.   gotoxy(dr,12);  write('    HiResColor(Color:Integer);');
  659.   gotoxy(dr,13);  write('    NoSound;');
  660.   gotoxy(dr,14);  write('    Palette(Color:Integer);');
  661.   Wait;
  662. end;
  663.  
  664. procedure Version2II;
  665. begin
  666.   gotoxy(dr,2);   write('VERSION 2 Part II');
  667.   gotoxy(dr,3);   write('  Procedures Part II :');
  668.   gotoxy(dr,4);   write('    Plot(X,Y,Color:Integer);');
  669.   gotoxy(dr,5);   write('    Sound(I:Integer);');
  670.   gotoxy(dr,6);   write('    TextBackground(Color:Integer);');
  671.   gotoxy(dr,7);   write('    TextColor(Color:Integer);');
  672.   gotoxy(dr,8);   write('    TextMode(Color:Integer);');
  673.   gotoxy(dr,9);   write('    Window(X1,Y1,X2,Y2,Color:Integer);');
  674.   gotoxy(dr,10);  write('  Functions :');
  675.   gotoxy(dr,11);  write('    MaxAvail:Integer;');
  676.   gotoxy(dr,12);  write('    WhereX:Integer;');
  677.   gotoxy(dr,13);  write('    WhereY:Integer;');
  678.   Wait;
  679. end;
  680.  
  681.  
  682.  
  683. { MAIN INTERUPT SERVICE PROCEDURES }
  684.  
  685.  
  686. procedure EditCommands;
  687. begin
  688.   repeat
  689.     PrintMenu(1);
  690.     case selection of
  691.       1 : CursorMoveI;
  692.       2 : CursorMoveII;
  693.       3 : InsertDelete;
  694.       4 : BlockCommands;
  695.       5 : MiscEditing;
  696.     end;
  697.     until selection = escape;
  698.     selection := 10;
  699. end;
  700.  
  701. procedure Syntax;
  702. begin
  703.   repeat
  704.     PrintMenu(2);
  705.     case selection of
  706.       1 : PrintType;
  707.       2 : PrintConst;
  708.       3 : PrintVar;
  709.       4 : PrintCase;
  710.       5 : RepeatWhile;
  711.       6 : IfFor;
  712.       7 : ProgProcFunc;
  713.       8 : ProgramStructure;
  714.     end;
  715.     until selection = escape;
  716.     selection := 10;
  717. end;
  718.  
  719. procedure ProcFunc;
  720. begin
  721.   repeat
  722.     PrintMenu(3);
  723.     case selection of
  724.       1 : InputOutput;
  725.       2 : Arithmetic;
  726.       3 : ScalarHeap;
  727.       4 : Strings;
  728.       5 : FileProc;
  729.       6 : FileFunc;
  730.       7 : TransferScreen;
  731.       8 : MiscProc;
  732.       9 : MiscFunc;
  733.     end;
  734.     until selection = escape;
  735.     selection := 10;
  736.  
  737. end;
  738.  
  739. procedure DOIT;
  740. begin
  741.   textcolor(7);
  742.   repeat
  743.     PrintMenu(0);
  744.     case selection of
  745.       1 : EditCommands;
  746.       2 : Syntax;
  747.       3 : ProcFunc;
  748.       4 : PrintDirectives;
  749.       5 : RuntimeErrors;
  750.       6 : IOErrors;
  751.       7 : StdIdentifiers;
  752.       8 : Version2I;
  753.       9 : Version2II;
  754.     end;
  755.   until selection = escape;
  756. end;
  757.  
  758.  
  759. procedure ProcessInt;                  { Start of interupt service }
  760. begin
  761. {when invoked, this procedure saves the registers into the structured constant
  762.  'REGS' and restores the ds from the previously saved integer constant 'saveds'}
  763.  
  764.     inline(
  765.     $53/                               {PUSH BX}
  766.     $BB/regs/                          {MOV BX,OFFSET REGS}
  767.     $2E/$89/$47/$00/                   {CS:MOV [BX]0,AX}
  768.     $58/                               {POP AX}
  769.     $2E/$89/$47/$02/                   {CS:MOV [BX]2,AX}
  770.     $2E/$89/$4F/$04/                   {CS:MOV [BX]4,CX}
  771.     $2E/$89/$57/$06/                   {CS:MOV [BX]6,DX}
  772.     $2E/$89/$6F/$08/                   {CS:MOV [BX]8,BP}
  773.     $2E/$89/$77/$0A/                   {CS:MOV [BX]A,SI}
  774.     $2E/$89/$7F/$0C/                   {CS:MOV [BX]C,DI}
  775.     $2E/$8C/$5F/$0E/                   {CS:MOV [BX]E,DS}
  776.     $2E/$8C/$47/$10/                   {CS:MOV [BX]10,ES}
  777.     $9C/                               {PUSHF}
  778.     $58/                               {POP AX}
  779.     $2E/$89/$47/$12/                   {CS:MOV [BX]12,AX}
  780.     $2E/$8E/$1E/saveds                 {CS:MOV DS,SAVEDS -- PUT PROPER DS}
  781.     );
  782.  
  783.   if halfreg.ah <> 0 then Intr(userint,regs) else
  784.   begin
  785.     Intr(userint,regs);
  786.     if (halfreg.ah = EntryChar) and (halfreg.al = $00) then
  787.     begin
  788.       savereg.ax := $0300;
  789.       savereg.bx := $0;
  790.       Intr($10,savereg);               { get cursor position }
  791.       cursorpos := savereg.dx;
  792.  
  793.       OpenWindow;                      { save text in window }
  794.       DOIT;
  795.       CloseWindow;                     { put back the text in the window }
  796.  
  797.       savereg.ax := $0200;
  798.       savereg.bx := $0;
  799.       savereg.dx := cursorpos;
  800.       Intr($10,savereg);               { restore cursor position }
  801.  
  802.       halfreg.ah := 0;
  803.       Intr(userint,regs);
  804.     end;
  805.   end;
  806.  
  807. {when invoked this routine restores the registers from the structure constant}
  808.  
  809.     inline(
  810.     $BB/REGS/                          {MOV BX,OFFSET REGS}
  811.     $2E/$8E/$47/$10/                   {CS:MOV ES,[BX]10}
  812.     $2E/$8E/$5F/$0E/                   {CS:MOV DS,[BX]0E}
  813.     $2E/$8B/$7F/$0C/                   {CS:MOV DI,[BX]0C}
  814.     $2E/$8B/$77/$0A/                   {CS:MOV SI,[BX]0A}
  815.     $2E/$8B/$6F/$08/                   {CS:MOV BP,[BX]08}
  816.     $2E/$8B/$57/$06/                   {CS:MOV DX,[BX]06}
  817.     $2E/$8B/$4F/$04/                   {CS:MOV CX,[BX]04}
  818.     $2E/$8B/$47/$00/                   {CS:MOV AX,[BX]00}
  819.     $2E/$FF/$77/$12/                   {CS:PUSH [BX]12}
  820.     $9D/                               {POPF}
  821.     $2E/$8B/$5F/$02/                   {CS:MOV BX,[BX]02}
  822.     $5D/                               {POP BP}  {restore the stack pointer}
  823.     $5D                                {POP BP}
  824.     );
  825.  
  826.     inline ($CA/$02/$00)               {RETF 02}
  827.  
  828. end;
  829.  
  830.  
  831. { PROGRAM 'THELP' }                    { Program installation }
  832. begin
  833.   SaveDS := dseg;
  834.   SaveReg.ax := $3500 + UserInt;
  835.   Intr($21,SaveReg);                   { get user interupt }
  836.  
  837.   if SaveReg.es <> $00 then
  838.     writeln('User Interupt in use -- cant install THELP.')
  839.   else
  840.  
  841.   begin
  842.     writeln('Installing THELP  --  Press < ALT "R" > to Recall help.');
  843.     writeln('                      Press   < ESC >   to  exit  help.');
  844.     savereg.ax := $3500 + KybdInt;
  845.     Intr($21,savereg);                 { get keyboard interupt }
  846.  
  847.     savereg.ax := $2500 + UserInt;
  848.     savereg.ds := savereg.es;
  849.     savereg.dx := savereg.bx;
  850.     Intr($21,savereg);                 { put in user interupt }
  851.  
  852.     savereg.ax := $2500 + KybdInt;
  853.     savereg.ds := cseg;
  854.     savereg.dx := ofs(ProcessInt);
  855.     Intr($21,savereg);                 { install our interupt processor }
  856.  
  857.     savereg.dx := ProgSize;
  858.     Intr($27,savereg);                 { terminate and stay resident }
  859.   end;
  860.   inline($CD/$20);                     { terminate if interupt in use }
  861. end.
  862.       3 : InsertDelete;
  863.       4 : BlockCommands;
  864.       5 : MiscEditing;
  865.     end;
  866.     until select