home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / TSCRPT30.ZIP / TSCRIPT.PAS < prev   
Encoding:
Pascal/Delphi Source File  |  1980-01-01  |  40.6 KB  |  1,482 lines

  1. Program TurboScript;
  2. {
  3. *****************************************************************************
  4. *                                                                           *
  5. *                  Turbo Script   ---  Version 3.0                          *
  6. *                                                                           *
  7. *                         By Kevin Menningen                                *
  8. *                                                                           *
  9. *        Copyright (c) 1985 by Kevin Menningen.   All Rights Reserved.      *
  10. *                                                                           *
  11. *             Special thanks to Tim Conner for his contributions.           *
  12. *                                                                           *
  13. *****************************************************************************
  14. }
  15.  
  16. {$C-,V-,K-}
  17. type
  18.     TempString = string[80];
  19. var
  20.     Words : array[1..500] of TempString;
  21.     Buffer : array[0..1325] of integer;
  22.     Row, Column, i, MaxRow, ScreenRow, Temp1, Temp2, Temp3, Keynum,
  23.          Num, code, Index, NumEnd, Inum : integer;
  24.     Inkey, SecInkey, Choice, ch : char;
  25.     Tabset : array[1..80] of boolean;
  26.     TextFile : Text;
  27.     TempWord, FileName, TypeSet, Oops : TempString;
  28.     Secnum, Row_One, Insertmode, Exit, Dir, Capsmode : boolean;
  29.     dosrec : record
  30.                ax,bx,cx,dx,bp,si,di,ds,es,flags : integer;
  31.              end;
  32.  
  33. procedure Fill_Buffer(Where : char;x,y,x1,y1 : integer);
  34. var j,k,l,Temprow,TempCol : integer;
  35.  
  36. begin
  37.    TempRow := Row;
  38.    TempCol := Column;
  39.    k := 0;
  40.    l := 0;
  41.    for i:=y-1 to y1-1 do begin
  42.       for j:= x-1 to x1-1 do begin
  43.          l := i*160+(j*2);
  44.          if Where = 'I' then Buffer[k] := Mem[$B800:l] else
  45.                Mem[$B800:l] := Buffer[k];
  46.          k := k + 1;
  47.       end;
  48.    end;
  49.    Row := TempRow;
  50.    Column := TempCol;
  51.    if Where = 'O' then Window(1,2,80,23);
  52. end;
  53.  
  54. function Replicate ( Count, Ascii : Integer ) : TempString;
  55. var Temp : TempString;
  56.       I  : Byte;
  57.  
  58. Begin
  59.   Temp := '';
  60.   For I := 1 to Count do
  61.     Temp := Temp + chr(Ascii);
  62.   Replicate := Temp;
  63. end;
  64.  
  65. procedure FuncEnd;
  66. begin
  67.    Temp3 := Length(Words[i]);
  68.    TempWord := Words[i];
  69.    repeat
  70.       ch := TempWord[Temp3];
  71.       Temp3 := Temp3 - 1;
  72.    until (ch<>chr(32)) or (Temp3 < 0);
  73.    Column := Temp3 + 2;
  74.    if Column < 1 then Column := 1;
  75. end;
  76.  
  77. procedure PrintWords(Start : integer);
  78. var j,l : integer;
  79.  
  80. begin
  81.    l := 0;
  82.    for i:=1 to 22 do begin
  83.       for j:= 1 to 79 do begin
  84.          l := i*160+((j-1)*2);
  85.          Move(Words[Start+i-1][j],Mem[$B800:l],1);
  86.       end;
  87.    end;
  88. end;
  89.  
  90. procedure Data_In(Line : integer;Var FileName : TempString);
  91. var
  92.    count, Maxcount : integer;
  93.    Letter : char;
  94.    NoGood, NameSet, ValidLetters, LowerCase : set of char;
  95.  
  96. begin
  97.    FileName := '--------.---';
  98.    count := 1;
  99.    GotoXY(1,Line-2);
  100.    Write('Default = .FIL');
  101.    GotoXY(1,10);
  102.    Write('Press Esc to Exit');
  103.    Exit := false;
  104.    ValidLetters := ['!'..'~'];
  105.    LowerCase := ['a'..'z'];
  106.    NoGood := ['*','<'..'>','[',']',' ','.'];
  107.    NameSet := ValidLetters - NoGood;
  108.    GotoXY(1,Line);
  109.    write(FileName);
  110.    GotoXY(1,Line);
  111.    Maxcount := Length(FileName);
  112.    repeat
  113.      GotoXY(count,Line);
  114.      read(Kbd, Letter);
  115.      if Letter in Lowercase then Letter := UpCase(Letter);
  116.      if (Letter = ' ') or (Letter = '.') then count := maxcount - 3;
  117.      if Letter <> '?' then begin
  118.         if Letter in NameSet then begin
  119.            FileName[count] := Letter;
  120.            GotoXY(1,Line);
  121.            Write(FileName);
  122.            count := count + 1;
  123.         end
  124.         else
  125.           if Letter = chr(8) then begin
  126.              if count = Pos('.',FileName) + 1 then count := count - 2
  127.                 else count := count - 1;
  128.              if count < 1 then count := 1;
  129.              FileName[count] := '-';
  130.              GotoXY(1,Line);
  131.              write(FileName);
  132.            end
  133.         else if not(ord(Letter) in [13,27,32,46]) then write(chr(7));
  134.         if count = Pos('.',FileName) then count := count + 1;
  135.      end else Dir := True;
  136.   until (count = Maxcount + 1) or (ord(Letter) in [13,27,63]);
  137.   if (ord(Letter) in [27,63]) or (count=1) then Exit := true else begin
  138.      if Copy(Filename, Maxcount-2,1) = '-' then begin
  139.         Filename := Copy(Filename, 1, Length(Filename)-4);
  140.         Filename := Filename + '.FIL';
  141.      end;
  142.      repeat
  143.         Delete(Filename,Pos('-',Filename),1);
  144.      until Pos('-',Filename)=0;
  145.      GotoXY(1,Line);
  146.      Write('                ');
  147.      GotoXY(1,Line);
  148.      Write(Filename);
  149.   end;
  150. end;
  151.  
  152. procedure Printrow;
  153. begin
  154.    Port[980]:=10;  Port[981]:=8;
  155.    Window(1,1,80,25);
  156.    GotoXY(60,1);
  157.    write(Row : 3);
  158.    GotoXY(75,1);
  159.    write(Column : 2);
  160.    Window(1,2,80,23);
  161.    GotoXY(Column, ScreenRow);
  162. end;
  163.  
  164. procedure CapsCheck;
  165. var Caps : integer;
  166.  
  167. begin
  168.    Caps := Mem[$40:$18];
  169.    if Caps = 64 then begin
  170.       CapsMode := not CapsMode;
  171.       Window(1,1,80,25);
  172.       GotoXY(13,1);
  173.       if CapsMode then write('Caps Lock') else write(Replicate(10,205));
  174.       Repeat Caps := Mem[$40:$18] until Caps = 0;
  175.       Window(1,2,80,23);
  176.       GotoXY(Column, ScreenRow);
  177.    end;
  178. end;
  179.  
  180. procedure Menu(Title, Choice1, Choice2, Choice3, Choice4, Choice5 : TempString);
  181. begin
  182.    Exit := false;
  183.    While KeyPressed do Read(Kbd,ch);
  184.    ClrScr;
  185.    writeln(Title);
  186.    writeln;
  187.    writeln('1. ',Choice1);
  188.    writeln('2. ',Choice2);
  189.    writeln('3. ',Choice3);
  190.    writeln('4. ',Choice4);
  191.    writeln('5. ',Choice5);
  192.    writeln;
  193.    write('? ');
  194.    GotoXY(1,10);
  195.    write('Press Esc to exit');
  196.    GotoXY(3,9);
  197.    read(Kbd, Choice);
  198.    If ord(Choice) = 27 then Exit := true else Val(Choice, Num, code);
  199.    if (code>0) or (Num>5) or (Num<1) then Num := 0;
  200. end;
  201.  
  202. procedure CommandWindow(Strg : TempString; x,y,x1,y1 : integer);
  203. begin
  204.    if Dir = false then Fill_Buffer('I',x,y,x1,y1);
  205.    Window(x,y,x1,y1);
  206.    ClrScr;
  207.    Window(1,2,80,23);
  208.    GotoXY(x,y-1);  Write(chr(213));
  209.    Write(Replicate((x1-1)-x,205));
  210.    Write(chr(184));
  211.    for i:=y to y1-2 do
  212.    begin
  213.       GotoXY(x, i);  Write(chr(179));
  214.       GotoXY(x1, i);  Write(chr(179));
  215.    end;
  216.    GotoXY(x, y1-1);
  217.    Write(chr(212));
  218.    Write(Replicate((x1-1)-x,205));
  219.    Write(chr(190));
  220.    Window(x+2,y+1,x1-2,y1-1);
  221.    GotoXY(1,1);
  222.    if Strg <> ' ' then begin
  223.       write(Replicate(x1-x-4,223));
  224.       GotoXY(1,2);
  225.       write(Strg);
  226.       GotoXY(1,3);
  227.       write(Replicate(x1-x-4,220));
  228.    end;
  229. end;
  230.  
  231. procedure ClearScreen;
  232. begin
  233.    CommandWindow(' ',28,6,52,18);
  234.    ClrScr;
  235.    GotoXY(1,3);
  236.    write('Clear Memory, Erase  Text?',chr(13),chr(10),chr(10));
  237.    write('ARE YOU SURE? (Y/N) ');
  238.    read(Kbd,Inkey);
  239.    write(Inkey);
  240.    if (Inkey = 'y') or (Inkey = 'Y') then begin
  241.         TempWord := Replicate(79,32);
  242.         for i := 1 to 500 do Words[i] := TempWord;
  243.         Row := 1;
  244.         ScreenRow := 1;
  245.         Column := 1;
  246.         MaxRow := 1;
  247.      end
  248.    else Exit := true;
  249. end;
  250.  
  251. function GetKey(var secnum : boolean; var Inkey : char) : boolean;
  252. begin
  253.    if KeyPressed then begin
  254.       GetKey := true;
  255.       dosrec.ax := $0800;
  256.       msdos(dosrec);
  257.       Inkey := chr(lo(dosrec.ax));
  258.       KeyNum := ord(Inkey);
  259.       Secnum := ord(Inkey) = 0;
  260.       if Secnum then begin
  261.          dosrec.ax := $0800;
  262.          msdos(dosrec);
  263.          Keynum := ord(chr(lo(dosrec.ax)));
  264.       end
  265.       else if ord(Inkey) <= 27 then Secnum := true else Secnum := false;
  266.    end
  267.    else begin
  268.       Getkey := false;
  269.       secnum := false;
  270.    end;
  271. end;
  272.  
  273. procedure InsertLine;
  274. begin
  275.    if Temp1 <> 3333 then InsLine;
  276.    for i := MaxRow + 1 downto Row do Words[i+1] := Words[i];
  277.    Words[Row] := Replicate(79,32);
  278.    MaxRow := MaxRow + 1;
  279. end;
  280.  
  281. procedure ScrollUp;
  282. begin
  283.    ScreenRow := 22;
  284.    GotoXY(1,1);
  285.    DelLine;
  286.    GotoXY(1, ScreenRow);
  287.    write(Words[Row]);
  288. end;
  289.  
  290. procedure Enter;
  291. begin
  292.   Row := Row + 1;
  293.   Oops := Words[Row];
  294.   ScreenRow := Screenrow + 1;
  295.   if ScreenRow > 22 then ScrollUp;
  296.   if InsertMode then begin
  297.      GotoXY(Column, ScreenRow-1);
  298.      ClrEol;
  299.      Sound(450);
  300.      Delay(20);
  301.      NoSound;
  302.      if Temp1 = 5555 then Column := Column + 1;
  303.      GotoXY(1,ScreenRow);
  304.      InsertLine;
  305.      Words[Row] := Copy(Words[Row-1],Column,79-Column) +
  306.                    Replicate(79-(79-Column),32);
  307.      Words[Row-1] := Copy(Words[Row-1],1,Column-1)+Replicate(79-Column,32);
  308.      FuncEnd;
  309.      if Temp1 = 5555 then Words[Row][Column] := Inkey;
  310.      GotoXY(1,ScreenRow);
  311.      TempWord := Replicate(79,32);
  312.      if Words[Row] <> Tempword then Write(Words[Row]);
  313.   end else Column := 1;
  314.   if row > MaxRow then MaxRow := Row;
  315.   GotoXY(Column, Screenrow);
  316. end;
  317.  
  318. procedure WordWrap;
  319. var Mode : boolean;
  320.  
  321. begin
  322.    Column := 79;
  323.    Temp1 := 5555;
  324.    TempWord := Words[Row];
  325.    Mode := InsertMode;
  326.  
  327.    repeat
  328.       Column := Column - 1;
  329.    until TempWord[Column] = chr(32);
  330.    if Column < 2 then Column := 2;
  331.    InsertMode := true;
  332.    Enter;
  333.    InsertMode := Mode;
  334.    Temp1 := 1;
  335.    Column := Column + 1;
  336. end;
  337.  
  338. procedure Character;
  339. begin
  340.    if Column = 79 then WordWrap else
  341.    begin
  342.       GotoXY(Column,ScreenRow);
  343.       write(Inkey);
  344.       Insert(Inkey, Words[Row], Column);
  345.       if not Insertmode then Delete(Words[Row],Column + 1,1);
  346.       Column := Column + 1;
  347.       if Column = 70 then begin
  348.          Sound(1010);
  349.          Delay(10);
  350.          NoSound;
  351.       end;
  352.    end;
  353. end;
  354.  
  355. procedure DeleteLine;
  356. begin
  357.    DelLine;
  358.    GotoXY(1, 22);
  359.    write(Words[Row+(23-ScreenRow)]);
  360.    for i := Row to MaxRow + 1 do Words[i] := Words[i+1];
  361.    MaxRow := MaxRow - 1;
  362.    if Row > MaxRow then MaxRow := Row;
  363. end;
  364.  
  365. procedure Del;
  366. begin
  367.    if Column >= 79 then Column := 78;
  368.    ch := Copy(Words[Row], Column, 1);
  369.    Delete(Words[Row], Column, 1);
  370.    Words[Row] := Words[Row] + ' ';
  371.    Port[980]:=10;  Port[981] := 8;
  372.    GotoXY(Column, ScreenRow);
  373.    TempWord := Copy(Words[Row],Column,79-Column);
  374.    if ScreenRow = 22 then write(TempWord) else writeln(TempWord);
  375. end;
  376.  
  377. procedure Backspace;
  378.   begin
  379.     if Column > 1 then begin
  380.        Column := Column - 1;
  381.        if Column < 79 then Del;
  382.     end else begin
  383.        i := Row;
  384.        FuncEnd;
  385.        Temp1 := Column-1;
  386.        i := Row-1;
  387.        FuncEnd;
  388.        Temp2 := Column-1;
  389.        if Temp1 + Temp2 <= 79 then begin
  390.           Sound(200);
  391.           Delay(20);
  392.           NoSound;
  393.           Words[Row-1] := Copy(Words[Row-1],1,Temp2) + Copy(Words[Row],1,Temp1) +
  394.                           Replicate(79-(Temp1+Temp2),32);
  395.           Words[Row] := Replicate(79,32);
  396.           GotoXY(1,ScreenRow-1);
  397.           Writeln(Words[Row-1]);
  398.           GotoXY(1,ScreenRow);
  399.           ClrEol;
  400.           DeleteLine;
  401.           Row := Row - 1;
  402.           Oops := Words[Row];
  403.           ScreenRow := ScreenRow - 1;
  404.           Column := Temp2 + 1;
  405.        end;
  406.     end;
  407.  end;
  408.  
  409. procedure CursorLeft;
  410. begin
  411.   column := column - 1;
  412.   if column < 1 then begin
  413.      column := 79;
  414.      if Row = 1 then Row := 1 else Row := Row - 1;
  415.      Oops := Words[Row];
  416.      if ScreenRow = 1 then ScreenRow := 1 else ScreenRow := ScreenRow - 1;
  417.   end
  418. end;
  419.  
  420. procedure CursorRight;
  421. begin
  422.    column := column + 1;
  423.    If Column > 79 then begin
  424.       Column := 1;
  425.       Row := Row + 1;
  426.       Oops := Words[Row];
  427.       if Row > MaxRow then MaxRow := Row;
  428.       If ScreenRow < 22 then ScreenRow := ScreenRow + 1 else ScrollUp;
  429.    end;
  430. end;
  431.  
  432. procedure CursorUp;
  433. begin
  434.    if row = 1 then Row_One := true else Row_One := false;
  435.    row := row - 1;
  436.    Oops := Words[Row];
  437.    if row < 1 then row := 1;
  438.    if (ScreenRow = 1) and not Row_One then begin
  439.        GotoXY(1,1);
  440.        InsLine;
  441.        GotoXY(1,1);
  442.        write(Words[Row]);
  443.    end;
  444.    ScreenRow := ScreenRow - 1;
  445.    if ScreenRow < 1 then ScreenRow := 1;
  446. end;
  447.  
  448. procedure CursorDown;
  449. begin
  450.   row := row + 1;
  451.   Oops := Words[Row];
  452.   if row > MaxRow then MaxRow := Row;
  453.   ScreenRow := ScreenRow + 1;
  454.   if ScreenRow > 22 then ScrollUp;
  455. end;
  456.  
  457. procedure DirGet  (Func, Asciiz : TempString; var FileName : TempString;
  458.                    var Error : Integer; Option : Integer);
  459. var
  460.    OurDTA : array [ 1..43 ] of byte;    { Data Transfer Area buffer }
  461.    CurDTAseg,                           { DTA segment before execution }
  462.    CurDTAofs,                           { DTA offset    "        "     }
  463.    OurDTAseg,                           { DTA segment and offset set after }
  464.    OurDTAofs          : integer;        { start of program }
  465.  
  466. begin
  467.     error := 0;
  468.     If Func = 'FIRST' then begin
  469.        Error := 0; {---------- Initialization processes ------------}
  470.        For I := 1 to 43 do OurDTA[I]:=0;        {Initialize our DTA Buffer}
  471.        dosrec.ax := $2F00;                      { Save Current DTA pointer}
  472.        Intr($21,dosrec);                        { to be restored later    }
  473.        CurDTASeg := dosrec.es;
  474.        CurDTAOfs := dosrec.bx;
  475.        error := dosrec.ax and $FF;
  476.        if error = 0 then begin
  477.           OurDTAseg := seg(OurDTA);           {Point DOS to our        }
  478.           OurDTAofs := ofs(OurDTA);           {DTA Buffer              }
  479.           dosrec.ax := $1A00;
  480.           dosrec.ds := OurDTASeg;
  481.           dosrec.dx := OurDTAOfs;
  482.           Intr($21,dosrec);
  483.           error := dosrec.ax and $FF;
  484.        end;
  485.        asciiz[length(asciiz)+1]:=chr(0); { Terminate name with hex00 }
  486.        dosrec.ax := $4E00;          { Get first directory entry }
  487.        dosrec.ds := seg(Asciiz);    { Point to the file mask }
  488.        dosrec.dx := ofs(Asciiz);
  489.        dosrec.dx := dosrec.dx + 1;    { Point past string's length byte }
  490.        dosrec.cx := Option;
  491.        end
  492.     else
  493.        dosrec.ax := $4F00;          {Get next directory entry}
  494.     Intr($21,dosrec);               { Execute MSDos call }
  495.     error := dosrec.ax and $FF;     { Get error return }
  496.     I := 1;
  497.     If error = 0 then
  498.     Repeat                        { Get name from the DTA area }
  499.         FileName[I]:=chr(mem[OurDTASeg:OurDTAOfs + 29 + I]);
  500.         I := I + 1;
  501.     Until (not (FileName[I - 1] in [' '..'~']));
  502.     FileName[0]:=chr(I-1)         { set string length because assigning }
  503.                                   { by element does not set length }
  504. end;
  505.  
  506. procedure PrintDir;
  507. var err,place : integer;
  508.     firstname, nextnames : TempString;
  509.  
  510. Begin
  511.    ClrScr;
  512.    DirGet('FIRST','????????.???'+chr(0),FIRSTNAME,err,8);
  513.    writeln('Directory of A: Volume name is ',FIRSTNAME);
  514.    writeln('Only Turbo Script files listed.',chr(13),chr(10));
  515.    DirGet('FIRST','A:????????.FIL'+chr(0),Firstname,err,3);
  516.    write(copy(Firstname,1,Pos('.',Firstname)-1));
  517.    place := 13;
  518.    repeat
  519.        if Place = 49 then begin
  520.           Writeln;
  521.           Place := 1;
  522.        end;
  523.        GotoXY(Place, WhereY);
  524.        DirGet('NEXT','A:????????.FIL'+chr(0),Nextnames,err,3);
  525.        Nextnames := Copy(Nextnames,1,pos('.',Nextnames)-1);
  526.        Write(Nextnames);
  527.        Place := Place + 12;
  528.    until err<>0;
  529.    dosrec.ax := $3600;
  530.    dosrec.dx := 0;
  531.    Intr($21, dosrec);
  532.    writeln;
  533.    writeln('      ',dosrec.bx,'k bytes free',chr(13),chr(10));
  534.    if Inum = 3333 then begin
  535.       writeln('Press any key to continue...');
  536.       read(Kbd, Choice);
  537.    end;
  538. end;
  539.  
  540. function Exist(Name : TempString) : boolean;
  541. begin
  542.    Assign(TextFile, Name);
  543.    {$I-}
  544.    Reset(TextFile);
  545.    {$I+}
  546.    Exist := (IOresult = 0);
  547. end;
  548.  
  549. procedure Warning;
  550. begin
  551.    ClrScr;
  552.    Writeln(chr(7),'<<<<<<<<<<>>>>>>>>>>  ');
  553.    writeln('That file already');
  554.    writeln('    exists.');
  555.    writeln;
  556.    writeln('Replace it (Y/N)?');
  557.    writeln;
  558.    writeln('<<<<<<<<<<>>>>>>>>>>');
  559.    GotoXY(19,6);
  560.    Read(Kbd, Choice);
  561.    GotoXY(19,6);
  562.    write(Choice);
  563.    if (Choice = 'n') or (Choice = 'N') then Exit := true;
  564. end;
  565.  
  566. overlay procedure Savefile;
  567. begin
  568.    Dir := false;
  569.    CommandWindow('     Save File',28,6,52,18);
  570.    GotoXY(1,5);
  571.    writeln('Enter File Name:');
  572.    Data_In(8, Filename);
  573.    if Dir = True then begin
  574.       Exit := false;
  575.       Fill_Buffer('O',28,6,52,18);
  576.       Fill_Buffer('I',2,3,78,19);
  577.       CommandWindow(' ',2,3,52,19);
  578.       PrintDir;
  579.       CommandWindow('     Save File',54,6,78,18);
  580.       GotoXY(1,5);
  581.       Writeln('Enter File Name:');
  582.       Data_In(8, Filename);
  583.    end;
  584.    if Exit = false then begin
  585.       if Exist(FileName) = true then Warning;
  586.       if Exit = false then begin
  587.          Rewrite(TextFile);
  588.          for i := 1 to MaxRow do Writeln(TextFile, Words[i]);
  589.          Close(TextFile);
  590.       end;
  591.    end;
  592.    if Dir=false then Fill_Buffer('O',28,6,52,18) else Fill_Buffer('O',2,3,78,19);
  593. end;
  594.  
  595. overlay procedure Loadfile(Title : TempString; Start : integer);
  596. begin
  597.    Dir := false;
  598.    Temp1 := 3333;
  599.    Temp2 := Row;
  600.    CommandWindow('     '+Title+' File',28,6,52,18);
  601.    GotoXY(1,5);
  602.    Writeln('Enter File Name:');
  603.    Data_In(8, Filename);
  604.    if Dir = True then begin
  605.       Exit := false;
  606.       Fill_Buffer('O',28,6,52,18);
  607.       Fill_Buffer('I',2,3,78,19);
  608.       CommandWindow(' ',2,3,52,19);
  609.       PrintDir;
  610.       CommandWindow('     '+Title+' File',54,6,78,18);
  611.       GotoXY(1,5);
  612.       Writeln('Enter File Name:');
  613.       Data_In(8, Filename);
  614.    end;
  615.    if Exit = false then if Exist(FileName)=true then begin
  616.       if Title='Load' then ClearScreen;
  617.       if Exit = false then begin
  618.          Row := Start;
  619.          While EOF(Textfile) = false do begin
  620.             if Title = 'Merge' then InsertLine;
  621.             Readln(TextFile, Words[Row]);
  622.             if Length(Words[Row]) >= 80 then Words[Row] := Copy(Words[Row], 1, 79);
  623.             if Title = 'Load' then MaxRow := MaxRow + 1;
  624.             Row := Row + 1;
  625.          end;
  626.          Temp1 := 1;
  627.          Close(TextFile);
  628.          Window(1,2,80,23);
  629.          ClrScr;
  630.          GotoXY(1,1);
  631.          if Title = 'Load' then begin
  632.             PrintWords(1);
  633.             Row := 1;
  634.          end else begin
  635.             Row := Temp2;
  636.             PrintWords(Row-ScreenRow+1);
  637.          end;
  638.          Oops := Words[Row];
  639.       end;
  640.    end
  641.    else if Exit = False then begin
  642.       ClrScr;
  643.       writeln(chr(7));
  644.       writeln('File does not exist');
  645.       Delay(1000);
  646.       Exit := true;
  647.       Row := Temp2;
  648.    end;
  649.    if Exit = true then begin
  650.       if Dir=false then Fill_Buffer('O',28,6,52,18) else Fill_Buffer('O',2,3,78,19);
  651.    end;
  652. end;
  653.  
  654. overlay procedure PrintFile;
  655. var Linespaces,RowNum,j,LineNum,Page : integer;
  656.     UnderMode, ItalicMode, BoldMode, PageNums : boolean;
  657.  
  658. procedure SetMargins;
  659. var  LeftMarg, RightMarg : integer;
  660.  
  661. begin
  662.    Menu('Select Top Margin:',' 1"',' 1 1/2"',' 2"',' 2 1/2"',' None');
  663.    if Num in [1..4] then begin
  664.       Temp1 := (Num + 1)*3;
  665.       ClrScr;
  666.       writeln('Set Horizontal       Margins (Y/N)');
  667.       read(Kbd, Choice);
  668.       if (Choice = 'Y') or (Choice = 'y') then begin
  669.           writeln;
  670.           writeln('Enter Left margin:');
  671.           Read(LeftMarg);
  672.           writeln;
  673.           writeln('Enter Right margin:');
  674.           Read(RightMarg);
  675.           Typeset := Typeset + chr(27) + chr(77) + chr(LeftMarg) +
  676.                                chr(27) + chr(81) + chr(RightMarg);
  677.       end;
  678.    end else Temp1 := 1;
  679. end;
  680.  
  681. procedure PrintTitle;
  682. var Titlename : TempString;
  683.     Spacing : integer;
  684.  
  685. begin
  686.   Dir := true;
  687.   CommandWindow('        Title',28,6,52,18);
  688.   Dir := false;
  689.   GotoXY(1,5);
  690.   writeln('Enter title:');
  691.   read(Titlename);
  692.   Write(Lst, chr(27), chr(71), chr(27), chr(69), chr(27), chr(14));
  693.   Spacing := 20 - Length(Titlename) div 2;
  694.   Spacing := Spacing + Length(Titlename);
  695.   writeln(Lst, Titlename : Spacing);
  696.   writeln(Lst, chr(27), chr(64), Typeset);
  697.   ClrScr;
  698.   GotoXY(1,3);
  699.   TextColor(White + Blink);
  700.   writeln('Printing...');
  701.   TextColor(White);
  702.   writeln;
  703.   writeln('<< Press any key >>');
  704.   writeln('<< to abort.     >>');
  705. end;
  706.  
  707. procedure Script(Style : integer);
  708. begin
  709.    Write(Lst, chr(27), chr(83), chr(Style));
  710.    Index := Index + 1;
  711.    repeat
  712.       Write(Lst, TempWord[Index]);
  713.       Index := Index + 1;
  714.    until not(TempWord[Index] in ['0'..'9','-']) = true;
  715.    write(Lst, chr(27), chr(84));
  716. end;
  717.  
  718. procedure Fonts(var Mode : boolean; Num : integer);
  719. begin
  720.    Mode := Not Mode;
  721.    if Num = 45 then begin
  722.       if Mode = true then Write(Lst, chr(27),chr(Num),chr(1)) else
  723.         Write(Lst, chr(27), chr(Num), chr(0));
  724.    end else if Mode = true then Write(Lst, chr(27), chr(Num)) else
  725.         Write(Lst, chr(27), chr(Num+1));
  726. end;
  727.  
  728.  
  729. begin  { Print File }
  730.    UnderMode := false;
  731.    Italicmode := false;
  732.    Boldmode := false;
  733.    PageNums := false;
  734.    Temp2 := Column;
  735.    CommandWindow('     Print file',28,6,52,18);
  736.    Typeset := chr(27)+chr(64);
  737.    GotoXY(1,7);
  738.    writeln('Press any key...');
  739.    repeat until KeyPressed;
  740.    repeat
  741.       Menu('Choose print style:', ' Elite', ' Boldface', ' Italic', ' Compressed', ' Continue');
  742.       Case Num of
  743.           1 : Typeset := Concat(Typeset,chr(27),chr(66),chr(2),
  744.                                 chr(27),chr(77),chr(11));
  745.           2 : Typeset := Concat(Typeset,chr(27),chr(71));
  746.           3 : Typeset := Concat(Typeset,chr(27),chr(52));
  747.           4 : Typeset := Concat(Typeset,chr(15),chr(27),chr(77),chr(32));
  748.           5 :;
  749.         else
  750.           if Exit = false then write(chr(7));
  751.         end;
  752.       if Num in [1..4] then begin
  753.          Sound(300);
  754.          Delay(50);
  755.          NoSound;
  756.          write(' Done.');
  757.          Delay(300);
  758.       end;
  759.    until (Num = 5) or (Exit = true);
  760.    if Exit = false then begin
  761.       SetMargins;
  762.       ClrScr;
  763.       writeln('Set line spacing:');
  764.       writeln;
  765.       writeln('1.  Single');
  766.       writeln('2.  Double');
  767.       writeln('3.  Triple');
  768.       writeln;
  769.       read(Kbd, Choice);
  770.       Val(Choice, Num, code);
  771.       if (Num in [1..3]) and (code = 0) then Linespaces := Num;
  772.       writeln;
  773.       Write('Do you want Page     Numbers? (Y/N): ');
  774.       read(Kbd, Choice);
  775.       if (Choice = 'Y') or (Choice = 'y') then PageNums := true;
  776.       While KeyPressed do Read(Kbd,Choice);
  777.       ClrScr;
  778.       Writeln('Scroll paper to perf');
  779.       Writeln('and press any key to');
  780.       writeln('print, or Esc to');
  781.       writeln('exit');
  782.       read(Kbd, Choice);
  783.       if ord(Choice) <> 27 then begin
  784.          ClrScr;
  785.          GotoXY(1,3);
  786.          TextColor(White + Blink);
  787.          writeln('Printing...');
  788.          TextColor(White);
  789.          writeln;
  790.          writeln('<< Press any key >>');
  791.          writeln('<< to abort.     >>');
  792.          writeln(Lst, Typeset);
  793.          RowNum:= 0;
  794.          LineNum := 0;
  795.          Page := 1;
  796.          for j := 1 to Temp1 do write(Lst,chr(10));
  797.          While (not KeyPressed) and (RowNum < MaxRow + 1) do begin
  798.             TempWord := Replicate(79,32);
  799.             RowNum := RowNum + 1;
  800.             LineNum := LineNum + LineSpaces;
  801.             if Copy(Words[RowNum],1,5) = 'Title' then PrintTitle
  802.             else begin
  803.                if Words[RowNum] <> TempWord then begin
  804.                   i := RowNum;
  805.                   FuncEnd;
  806.                   TempWord := Copy(Words[RowNum],1,Column);
  807.                   Index := 0;
  808.                   repeat
  809.                      Index := Index + 1;
  810.                      case TempWord[Index] of
  811.                         '\' : Fonts(UnderMode,45);
  812.                         '~' : Script(0);
  813.                         '|' : Script(1);
  814.                         '√' : Fonts(ItalicMode,52);
  815.                         '■' : Fonts(BoldMode,71);
  816.                      else Write(Lst, TempWord[Index]);
  817.                      end;
  818.                   until Index >= Length(TempWord);
  819.                   Write(Lst, chr(13));
  820.                end;
  821.                for j := 1 to Linespaces do write(Lst, chr(10));
  822.             end;
  823.             if (LineNum = (66-Temp1*2)) and (Temp1 > 2) then begin
  824.                LineNum := 0;
  825.                Page := Page + 1;
  826.                for j := 1 to Temp1 do write(Lst, chr(10));
  827.                if PageNums then begin
  828.                   write(Lst, chr(10),chr(10),Replicate(73,32),'Page ',Page);
  829.                   for j := 1 to Temp1-2 do write(Lst, chr(10));
  830.                end else for j := 1 to Temp1 do write(Lst, chr(10));
  831.             end;
  832.          end;
  833.          if KeyPressed then Read(Kbd, Choice);
  834.       end;
  835.    end;
  836.    Column := Temp2;
  837.    GotoXY(1,3);
  838.    Writeln('            ');
  839.    Fill_Buffer('O',28,6,52,18);
  840. end;
  841.  
  842. overlay procedure Menu_S_R;
  843.  
  844. procedure Search;
  845. var SearchString, Temp : TempString;
  846.     Pointer, Position, Line, Len : integer;
  847.  
  848. begin
  849.    Line := 2;
  850.    SearchString := '';
  851.    CommandWindow('       Search',28,6,52,18);
  852.    GotoXY(1, 5);
  853.    writeln('Enter String: ');
  854.    writeln;
  855.    write('? ');
  856.    read(SearchString);
  857.    Len := Length(SearchString);
  858.    Window(1,2,80,23);
  859.    ClrScr;
  860.    for i := 1 to MaxRow do begin
  861.       Pointer := Pos(SearchString, Words[i]);
  862.       if (Exit = false) and (Pointer > 0) then begin
  863.          Temp := Words[i];
  864.          Position := Pointer;
  865.          GotoXY(1, Line);
  866.          LowVideo;
  867.          write(Temp);
  868.          NormVideo;
  869.          While Pointer > 0 do begin
  870.             GotoXY(Position, Line);
  871.             write(Copy(Temp, Pointer, Len));
  872.             Temp := Copy(Temp, Pointer + Len + 1,
  873.                          80 - Pointer + Len + 1);
  874.             Pointer := Pos(SearchString, Temp);
  875.             Position := Position + Pointer + Len;
  876.          end;
  877.          writeln;
  878.          Line := Line + 1;
  879.          if Line = 20 then begin
  880.             GotoXY(1, 22);
  881.             write('Press any key to continue or Esc to exit ...');
  882.             read(Kbd, Choice);
  883.             if ord(Choice) = 27 then Exit := true else begin
  884.                ClrScr;
  885.                line := 2;
  886.             end;
  887.          end;
  888.          if line > 2 then begin
  889.             read(Kbd, Choice);
  890.             if ord(Choice) = 27 then Exit := true;
  891.          end;
  892.       end;
  893.    end;
  894.    writeln(chr(13),chr(10),chr(10));
  895.    writeln('End of search');
  896.    repeat until Keypressed;
  897. end;
  898.  
  899. procedure Replace;
  900. var SearchString, Replacement : TempString;
  901.     Pointer, Line, Len : integer;
  902.  
  903. begin
  904.    Line := 2;
  905.    SearchString := '';
  906.    Replacement := '';
  907.    CommandWindow('      Replace',28,6,52,18);
  908.    GotoXY(1, 5);
  909.    writeln('Enter String: ');
  910.    writeln;
  911.    write('? ');
  912.    read( SearchString);
  913.    writeln;
  914.    writeln('Enter Replacement:');
  915.    writeln;
  916.    write('? ');
  917.    read( Replacement);
  918.    Len := Length(Replacement);
  919.    Window(1,2,80,23);
  920.    ClrScr;
  921.    for i := 1 to MaxRow do begin
  922.       Pointer := Pos(SearchString, Words[i]);
  923.       if (Pointer > 0) and (Exit = false) then begin
  924.          GotoXY(1, Line);
  925.          LowVideo;
  926.          write(Words[i]);
  927.          NormVideo;
  928.          GotoXY(Pointer, Line);
  929.          write(Copy(Words[i], Pointer, Length(SearchString)));
  930.          GotoXY(1,22);
  931.          write('Replace Y/N');
  932.          read(Kbd, Choice);
  933.          if ord(Choice) = 27 then Exit := true else if (Choice = 'Y') or
  934.          (Choice = 'y') then begin
  935.             Words[i] := Copy(Words[i],1,Pointer-1) + Replacement +
  936.                         Copy(Words[i], Pointer + Length(SearchString), 80-Len+1);
  937.             GotoXY(1, Line);
  938.             LowVideo;
  939.             write(Words[i]);
  940.             NormVideo;
  941.             GotoXY(Pointer, Line);
  942.             write(Copy(Words[i], Pointer, Len));
  943.          end
  944.          else begin
  945.             GotoXY(80, Line);
  946.             write('N');
  947.          end;
  948.          Line := Line + 1;
  949.          if Line = 20 then begin
  950.             writeln('Press any key to continue or Esc to exit ...');
  951.             read(Kbd, Choice);
  952.             if ord(Choice) = 27 then Exit := true else begin
  953.                ClrScr;
  954.                line := 2;
  955.             end;
  956.          end;
  957.       end;
  958.    end;
  959.    writeln;
  960.    write('End of replace');
  961.    repeat until Keypressed;
  962. end;
  963.  
  964. begin  {Menu_S_R}
  965.    CommandWindow('  Search / Replace',28,6,52,18);
  966.    Exit := false;
  967.    GotoXY(1,5);
  968.    Writeln('Enter Choice: ');
  969.    writeln;
  970.    writeln('1.  Search');
  971.    writeln('2.  Replace');
  972.    writeln;
  973.    write('? ');
  974.    GotoXY(1,10);
  975.    write('Press Esc to exit');
  976.    read(Kbd, Choice);
  977.    if ord(Choice) = 27 then Exit := true else Val(Choice, Num, code);
  978.    if (Exit = false) and (Num in [1,2]) then
  979.       case Num of
  980.          1 : Search;
  981.          2 : Replace;
  982.         end
  983.       else begin
  984.          if Exit = false then write(chr(7));
  985.          Fill_Buffer('O',28,6,52,18);
  986.          Exit := true;
  987.       end;
  988.    if Exit = false then begin
  989.       ClrScr;
  990.       GotoXY(1,1);
  991.       PrintWords(Row-ScreenRow+1);
  992.    end;
  993. end;
  994.  
  995. overlay procedure DosMenu;
  996.  
  997. procedure DelFile;
  998. begin
  999.   ClrScr;
  1000.   Dir := false;
  1001.   writeln('Enter file to Delete:');
  1002.   Data_In(4, FileName);
  1003.   if Dir = True then begin
  1004.       Exit := false;
  1005.       Fill_Buffer('O',28,6,52,18);
  1006.       Fill_Buffer('I',2,3,78,19);
  1007.       CommandWindow(' ',2,3,52,19);
  1008.       PrintDir;
  1009.       CommandWindow(' ',54,6,78,18);
  1010.       Writeln('Enter File Name:');
  1011.       Data_In(4, Filename);
  1012.   end;
  1013.   if (Exist(FileName) = true) and (Exit=false) then begin
  1014.      Erase(Textfile);
  1015.      GotoXY(1,6);
  1016.      writeln('File deleted');
  1017.      Delay(1000);
  1018.   end
  1019.    else begin
  1020.       GotoXY(1,6);
  1021.       if Exit=false then writeln(chr(7),'File does not exist');
  1022.       Delay(1000);
  1023.    end;
  1024. end;
  1025.  
  1026. procedure RenFile;
  1027. var OldName, NewName : TempString;
  1028.  
  1029. begin
  1030.    ClrScr;
  1031.    Writeln('Enter old file name:');
  1032.    Data_In(4, OldName);
  1033.    if Dir = True then begin
  1034.       Exit := false;
  1035.       Fill_Buffer('O',28,6,52,18);
  1036.       Fill_Buffer('I',2,3,78,19);
  1037.       CommandWindow(' ',2,3,52,19);
  1038.       PrintDir;
  1039.       CommandWindow(' ',54,6,78,18);
  1040.       Writeln('Enter old File Name:');
  1041.       Data_In(4, OldName);
  1042.    end;
  1043.    if (Exist(OldName) = true) and (Exit=false) then begin
  1044.       Close(Textfile);
  1045.       ClrScr;
  1046.       writeln('Enter new name:');
  1047.       Data_In(4, NewName);
  1048.       if (Exist(NewName) = false) and (Exit=false) then begin
  1049.          Close(Textfile);
  1050.          Assign(Textfile, OldName);
  1051.          Rename(Textfile, NewName);
  1052.          Close(Textfile);
  1053.       end
  1054.       else begin
  1055.          GotoXY(1,8);
  1056.          if Exit=false then write(chr(7),'New file already exists');
  1057.          Delay(1000);
  1058.       end;
  1059.    end
  1060.    else begin
  1061.       GotoXY(1,8);
  1062.       if Exit=false then write(chr(7),'File does not exist');
  1063.       Delay(1000);
  1064.    end;
  1065. end;
  1066.  
  1067. procedure Copyfile;
  1068. var Firstname, SecondName : TempString;
  1069.     SecondFile : Text;
  1070.        There : boolean;
  1071.  
  1072. begin
  1073.    ClrScr;
  1074.    Writeln('Enter source file:');
  1075.    Data_In(4, Firstname);
  1076.    if Dir = True then begin
  1077.       Exit := false;
  1078.       Fill_Buffer('O',28,6,52,18);
  1079.       Fill_Buffer('I',2,3,78,19);
  1080.       CommandWindow(' ',2,3,52,19);
  1081.       PrintDir;
  1082.       CommandWindow(' ',54,6,78,18);
  1083.       Writeln('Enter Source File:');
  1084.       Data_In(4, FirstName);
  1085.    end;
  1086.    if (Exist(FirstName) = true) and (Exit=false) then begin
  1087.       ClrScr;
  1088.       writeln('Enter Target File:');
  1089.       Data_In(4, SecondName);
  1090.       Assign(SecondFile, SecondName);
  1091.       {$I-}
  1092.       Reset(SecondFile);
  1093.       {$I+}
  1094.       There := (IOresult = 0);
  1095.       if (There = false) and (Exit=False) then begin
  1096.          Close(SecondFile);
  1097.          Rewrite(SecondFile);
  1098.          writeln;
  1099.          writeln;
  1100.          writeln('Copying......');
  1101.          while EOF(Textfile) = false do begin
  1102.             Readln(Textfile, TempWord);
  1103.             Writeln(SecondFile, TempWord);
  1104.             TempWord := '';
  1105.          end;
  1106.          Close(Textfile);
  1107.          Close(SecondFile);
  1108.       end
  1109.       else begin
  1110.          GotoXY(1,8);
  1111.          if Exit=false then write(chr(7),'New file already exists');
  1112.          Delay(1000);
  1113.       end;
  1114.    end
  1115.    else begin
  1116.       GotoXY(1,8);
  1117.       if Exit=false then write(chr(7),'File does not exist');
  1118.       Delay(1000);
  1119.    end;
  1120. end;
  1121.  
  1122. begin  {DosMenu}
  1123.    Inum := 0;
  1124.    Dir := false;
  1125.    CommandWindow(' ',28,6,52,18);
  1126.    Menu('      DOS Menu',' Directory',' Delete',' Rename',' Copy file',
  1127.                          ' Exit to DOS');
  1128.    if Exit = false then begin
  1129.       case Num of
  1130.          1 : begin
  1131.                Fill_Buffer('O',28,6,52,18);
  1132.                CommandWindow(' ',2,3,52,19);
  1133.                Inum := 3333;
  1134.                PrintDir;
  1135.                Fill_Buffer('O',2,3,52,19);
  1136.              end;
  1137.          2 : DelFile;
  1138.          3 : RenFile;
  1139.          4 : CopyFile;
  1140.          5 : begin
  1141.                 ClrScr;
  1142.                 GotoXY(1,4);
  1143.                 Writeln('Exit Turbo Script,');
  1144.                 Writeln;
  1145.                 Write('Erase memory (Y/N)? ');
  1146.                 Read(Kbd, Choice);
  1147.                 if (Choice = 'Y') or (Choice = 'y') then NumEnd := 9999
  1148.                      else NumEnd := 0;
  1149.              end;
  1150.       else write(chr(7));
  1151.       end; { case }
  1152.    end;
  1153.    if (Num <> 1) and (Num <> 5) then begin
  1154.       if Dir = false then Fill_Buffer('O',28,6,52,18) else
  1155.          Fill_Buffer('O',2,3,78,19);
  1156.    end;
  1157. end;
  1158.  
  1159. overlay procedure Initialize;
  1160. const
  1161.     Digits: array[1..10] of char = ('1','2','3','4','5','6','7','8','9','0');
  1162.     Positions: array[1..10] of integer = (1,8,18,25,33,39,49,59,67,74);
  1163.  
  1164. begin
  1165.     CrtInit;
  1166.     ClrScr;
  1167.     Row := 1;
  1168.     Column := 1;
  1169.     ScreenRow := 1;
  1170.     MaxRow := 1;
  1171.     Window(1,1,80,25);
  1172.     GotoXY(1,1);
  1173.     Write(Replicate(80,205));
  1174.     GotoXY(1,24);
  1175.     Write(Replicate(80,196));
  1176.     GotoXY(34,1);
  1177.     Write('Turbo Script');
  1178.     GotoXY(54,1);
  1179.     writeln('Row = ',Row : 3,'  Column = ',Column : 2);
  1180.     GotoXY(1,25);
  1181.     LowVideo;
  1182.     write('Help ':6,'Ser/Rep ':10,'Tabs ':7,'Title ':8,'DOS ':6);
  1183.     write('InsLine ':10,'DelLine ':10,'Print ':8,'Load ':7,'Save ':7);
  1184.     NormVideo;
  1185.     for i := 1 to 10 do begin
  1186.        GotoXY(Positions[i], 25);
  1187.        write(Digits[i]);
  1188.      end;
  1189.     Window(1,2,80,23);
  1190.     TempWord := Replicate(79,32);
  1191.     for i:=1 to 500 do Words[i] := TempWord;
  1192.     TempWord := '';
  1193.     Insertmode := false;
  1194.     Dir := false;
  1195.     CapsMode := false;
  1196.     Mem[$40:$17] := 0;
  1197.     Exit := false;
  1198.     NumEnd := 1;
  1199.     for i := 1 to 80 do Tabset[i] := false;
  1200.     Tabset[6] := true;
  1201.     Tabset[40] := true;
  1202. end;
  1203.  
  1204. procedure TabMenu;
  1205. begin
  1206.    Window(1,1,80,25);
  1207.    GotoXY(1,1);
  1208.    write('Tabs '); LowVideo; Write ('- ['); NormVideo; write('S');
  1209.    LowVideo; Write(']et, ['); NormVideo; write('C'); LowVideo; write(']lear, [');
  1210.    NormVideo; Write('P'); LowVideo; Write(']urge: '); NormVideo;
  1211.    read(Kbd, Choice);
  1212.       if Choice in ['s','S'] then Tabset[Column] := true;
  1213.       if Choice in ['c','C'] then Tabset[Column] := false;
  1214.       if Choice in ['p','P'] then for i := 1 to 79 do Tabset[i] := false;
  1215.    if not(Choice in ['s','c','p','S','C','P']) then write(chr(7));
  1216.    GotoXY(1,1);
  1217.    write(Replicate(33,205));
  1218.    Window(1,2,80,25);
  1219.    CapsMode := Not CapsMode;
  1220.    CapsCheck;
  1221. end;
  1222.  
  1223. procedure PrevWord;
  1224. begin
  1225.    TempWord := Words[Row];
  1226.    Index := Column;
  1227.    repeat
  1228.       Index := Index - 1;
  1229.       ch := TempWord[Index];
  1230.    until ch <> ' ';
  1231.    repeat
  1232.       Index := Index - 1;
  1233.       ch := TempWord[Index];
  1234.    until (ch = ' ') or (Index < 1);
  1235.    Column := Index + 1;
  1236.    if Column < 1 then Column := 1;
  1237. end;
  1238.  
  1239. procedure NextWord;
  1240. begin
  1241.    TempWord := Words[Row];
  1242.    Index := Column;
  1243.    repeat
  1244.       Index := Index + 1;
  1245.       ch := TempWord[Index];
  1246.    until (ch = ' ') or (Index > 79);
  1247.    repeat
  1248.       Index := Index + 1;
  1249.       ch := TempWord[Index];
  1250.    until ch <> ' ';
  1251.    Column := Index;
  1252.    if Column > 79 then Column := 79;
  1253. end;
  1254.  
  1255. procedure Help;
  1256. begin
  1257.    Assign(TextFile, 'HELP.HLP');
  1258.    Reset(TextFile);
  1259.    While EOF(Textfile) = false do begin
  1260.       ClrScr;
  1261.       GotoXY(1,1);
  1262.       Index := 0;
  1263.       NormVideo;
  1264.       repeat
  1265.          Readln(TextFile, TempWord);
  1266.          Index := Index + 1;
  1267.          writeln(TempWord);
  1268.       until (Index = 20) or (EOF(TextFile)=true);
  1269.       LowVideo;
  1270.       GotoXY(1,22);
  1271.       Write('      < Press');
  1272.       NormVideo;
  1273.       Write(' ENTER ');
  1274.       LowVideo;
  1275.       Write('to continue >');
  1276.       read(Kbd, Choice);
  1277.    end;
  1278.    Close(TextFile);
  1279.    NormVideo;
  1280.    ClrScr;
  1281.    GotoXY(1,1);
  1282.    PrintWords(Row-ScreenRow+1);
  1283. end;
  1284.  
  1285. procedure Ascii;
  1286. var Ascnum, Repeats, r : integer;
  1287.  
  1288. begin
  1289.    Window(1,1,80,25);
  1290.    GotoXY(1,1);
  1291.    Write('Enter ASCII code number: --- ');
  1292.    GotoXY(26,1);
  1293.    Readln(Ascnum);
  1294.    GotoXY(1,1);
  1295.    Write('Enter number of repeats: --  ');
  1296.    GotoXY(26,1);
  1297.    Readln(Repeats);
  1298.    if not(Repeats in [1..79]) then Repeats := 1;
  1299.    GotoXY(1,1);
  1300.    Write(Replicate(30,205));
  1301.    If Ascnum < 255 then begin
  1302.       Window(1,2,80,23);
  1303.       for r := 1 to Repeats do begin
  1304.          GotoXY(Column,ScreenRow);
  1305.          Inkey := chr(Ascnum);
  1306.          Character;
  1307.       end;
  1308.    end
  1309.     else write(chr(7));
  1310.    CapsMode := not CapsMode;
  1311.    CapsCheck;
  1312.    Window(1,2,80,23);
  1313. end;
  1314.  
  1315. procedure MemoryFilled;
  1316. begin
  1317.    CommandWindow(' ',28,6,52,18);
  1318.    GotoXY(1,2);
  1319.    Writeln(chr(7),'You have used up all');
  1320.    Writeln('Available memory in');
  1321.    Writeln('Turbo Script. Please');
  1322.    Writeln('save your file now');
  1323.    Writeln('and continue.');
  1324.    Delay(3000);
  1325.    SaveFile;
  1326.    TempWord := Replicate(79,32);
  1327.    for i:=1 to 500 do Words[i]:=TempWord;
  1328.    ClrScr;
  1329.    Row := 1;  ScreenRow := 1;
  1330.    Column := 1;
  1331. end;
  1332.  
  1333. procedure EndFile;
  1334. begin
  1335.    Row := MaxRow + 1;
  1336.    Oops := Words[Row];
  1337.    ScreenRow := 12;
  1338.    Column := 1;
  1339.    Temp1 := Row-11;
  1340.    GotoXY(1,1);
  1341.    TempWord := Replicate(79,32);
  1342.    PrintWords(Temp1);
  1343. end;
  1344.  
  1345. procedure HandleFunc;
  1346. begin
  1347.    case Keynum of
  1348.      8 : Backspace;
  1349.      9 : begin
  1350.             if Column < 79 then begin
  1351.                repeat
  1352.                   Column := Column + 1;
  1353.                until (Tabset[Column] = true) or (Column = 79);
  1354.             end;
  1355.          end;
  1356.     13 : Enter;
  1357.     15 : begin
  1358.             if Column > 1 then begin
  1359.                repeat
  1360.                   Column := Column - 1;
  1361.                until (Tabset[Column] = true) or (Column = 1);
  1362.             end;
  1363.           end;
  1364.     22 : begin
  1365.             Words[Row] := Oops;
  1366.             GotoXY(1, ScreenRow);
  1367.             write(Words[Row]);
  1368.          end;
  1369.     23 : begin
  1370.             Inkey := chr(251);
  1371.             Character;
  1372.          end;
  1373.     27 : begin
  1374.             Column := 1;
  1375.             GotoXY(1, WhereY);
  1376.             ClrEol;
  1377.             Words[Row] := Replicate(79,32);
  1378.          end;
  1379.     30 : Ascii;
  1380.     48 : begin
  1381.             Inkey := chr(254);
  1382.             Character;
  1383.          end;
  1384.     50 : LoadFile('Merge',Row);
  1385.     59 : Help;
  1386.     60 : Menu_S_R;
  1387.     61 : TabMenu;
  1388.     62 : begin
  1389.             Words[Row] := 'Title' + Replicate(74,32);
  1390.             GotoXY(1, ScreenRow);
  1391.             Write(Words[Row]);
  1392.             Enter;
  1393.          end;
  1394.     63 : DosMenu;
  1395.     64 : Insertline;
  1396.     65 : Deleteline;
  1397.     66 : PrintFile;
  1398.     67 : Loadfile('Load',1);
  1399.     68 : Savefile;
  1400.     71 : Column := 1;
  1401.     72 : CursorUp;
  1402.     73 : begin
  1403.             Row := Row - 21;
  1404.             if Row < 1 then Row := 1;
  1405.             if Row-ScreenRow < 1 then ScreenRow := Row;
  1406.             PrintWords(Row-ScreenRow+1);
  1407.             Oops := Words[Row];
  1408.          end;
  1409.     75 : CursorLeft;
  1410.     77 : CursorRight;
  1411.     79 : begin
  1412.             i := Row;
  1413.             FuncEnd;
  1414.          end;
  1415.     80 : CursorDown;
  1416.     81 : begin
  1417.             if Row + 21 < 500 then begin
  1418.                Row := Row + 21;
  1419.                Oops := Words[Row];
  1420.                PrintWords(Row-ScreenRow+1);
  1421.             end;
  1422.          end;
  1423.     82 : if Insertmode then Insertmode := false
  1424.               else Insertmode := true;
  1425.     83 : Del;
  1426.    115 : PrevWord;
  1427.    116 : NextWord;
  1428.    117 : begin
  1429.             ClrEol;
  1430.             Words[Row] := Copy(Words[Row], 1, Column-1) + Replicate(79-Column+1, 32);
  1431.          end;
  1432.    118 : EndFile;
  1433.    119 : begin
  1434.             ClearScreen;
  1435.             Fill_Buffer('O',28,6,52,18);
  1436.             if Exit = false then begin
  1437.                ClrScr;
  1438.                ScreenRow := 1;
  1439.             end;
  1440.          end;
  1441.    132 : begin
  1442.            GotoXY(1,1);
  1443.            if Row > ScreenRow then PrintWords(1);
  1444.            Row := 1;
  1445.            Column := 1;
  1446.            ScreenRow := 1;
  1447.          end;
  1448.    else
  1449.      Sound(200);
  1450.      Delay(300);
  1451.      NoSound;
  1452.    end;
  1453. end;
  1454.  
  1455. begin
  1456.   Initialize;
  1457.   PrintRow;
  1458.   repeat
  1459.     Secnum := false;
  1460.     if Getkey(Secnum, Inkey) then begin
  1461.        if Secnum then HandleFunc else Character;
  1462.        PrintRow;
  1463.        Exit := false;
  1464.        if Length(Words[Row]) > 79 then Words[Row] := Copy(Words[Row],1,79);
  1465.        if Insertmode then begin
  1466.          Port[980]:=10;  Port[981]:=8;
  1467.          GotoXY(Column, ScreenRow);
  1468.          TempWord := Copy(Words[Row],Column,79-Column);
  1469.          if ScreenRow = 22 then write(TempWord) else writeln(TempWord);
  1470.        end;
  1471.        GotoXY(Column , ScreenRow);
  1472.     end;
  1473.     if Row > 500 then MemoryFilled;
  1474.     CapsCheck;
  1475.     Port[980]:=10;
  1476.     if InsertMode then Port[981]:=4 else Port[981]:=7;
  1477.     Port[980]:=11;  Port[981]:=7;
  1478.   until NumEnd = 9999;
  1479.   Window(1,1,80,25);
  1480.   ClrScr;
  1481. end.
  1482.