home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / HELP.ZIP / HELP.PAS
Encoding:
Pascal/Delphi Source File  |  1987-11-08  |  31.3 KB  |  853 lines

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