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