home *** CD-ROM | disk | FTP | other *** search
- Program TurboScript;
- {
- *****************************************************************************
- * *
- * Turbo Script --- Version 3.0 *
- * *
- * By Kevin Menningen *
- * *
- * Copyright (c) 1985 by Kevin Menningen. All Rights Reserved. *
- * *
- * Special thanks to Tim Conner for his contributions. *
- * *
- *****************************************************************************
- }
-
- {$C-,V-,K-}
- type
- TempString = string[80];
- var
- Words : array[1..500] of TempString;
- Buffer : array[0..1325] of integer;
- Row, Column, i, MaxRow, ScreenRow, Temp1, Temp2, Temp3, Keynum,
- Num, code, Index, NumEnd, Inum : integer;
- Inkey, SecInkey, Choice, ch : char;
- Tabset : array[1..80] of boolean;
- TextFile : Text;
- TempWord, FileName, TypeSet, Oops : TempString;
- Secnum, Row_One, Insertmode, Exit, Dir, Capsmode : boolean;
- dosrec : record
- ax,bx,cx,dx,bp,si,di,ds,es,flags : integer;
- end;
-
- procedure Fill_Buffer(Where : char;x,y,x1,y1 : integer);
- var j,k,l,Temprow,TempCol : integer;
-
- begin
- TempRow := Row;
- TempCol := Column;
- k := 0;
- l := 0;
- for i:=y-1 to y1-1 do begin
- for j:= x-1 to x1-1 do begin
- l := i*160+(j*2);
- if Where = 'I' then Buffer[k] := Mem[$B800:l] else
- Mem[$B800:l] := Buffer[k];
- k := k + 1;
- end;
- end;
- Row := TempRow;
- Column := TempCol;
- if Where = 'O' then Window(1,2,80,23);
- end;
-
- function Replicate ( Count, Ascii : Integer ) : TempString;
- var Temp : TempString;
- I : Byte;
-
- Begin
- Temp := '';
- For I := 1 to Count do
- Temp := Temp + chr(Ascii);
- Replicate := Temp;
- end;
-
- procedure FuncEnd;
- begin
- Temp3 := Length(Words[i]);
- TempWord := Words[i];
- repeat
- ch := TempWord[Temp3];
- Temp3 := Temp3 - 1;
- until (ch<>chr(32)) or (Temp3 < 0);
- Column := Temp3 + 2;
- if Column < 1 then Column := 1;
- end;
-
- procedure PrintWords(Start : integer);
- var j,l : integer;
-
- begin
- l := 0;
- for i:=1 to 22 do begin
- for j:= 1 to 79 do begin
- l := i*160+((j-1)*2);
- Move(Words[Start+i-1][j],Mem[$B800:l],1);
- end;
- end;
- end;
-
- procedure Data_In(Line : integer;Var FileName : TempString);
- var
- count, Maxcount : integer;
- Letter : char;
- NoGood, NameSet, ValidLetters, LowerCase : set of char;
-
- begin
- FileName := '--------.---';
- count := 1;
- GotoXY(1,Line-2);
- Write('Default = .FIL');
- GotoXY(1,10);
- Write('Press Esc to Exit');
- Exit := false;
- ValidLetters := ['!'..'~'];
- LowerCase := ['a'..'z'];
- NoGood := ['*','<'..'>','[',']',' ','.'];
- NameSet := ValidLetters - NoGood;
- GotoXY(1,Line);
- write(FileName);
- GotoXY(1,Line);
- Maxcount := Length(FileName);
- repeat
- GotoXY(count,Line);
- read(Kbd, Letter);
- if Letter in Lowercase then Letter := UpCase(Letter);
- if (Letter = ' ') or (Letter = '.') then count := maxcount - 3;
- if Letter <> '?' then begin
- if Letter in NameSet then begin
- FileName[count] := Letter;
- GotoXY(1,Line);
- Write(FileName);
- count := count + 1;
- end
- else
- if Letter = chr(8) then begin
- if count = Pos('.',FileName) + 1 then count := count - 2
- else count := count - 1;
- if count < 1 then count := 1;
- FileName[count] := '-';
- GotoXY(1,Line);
- write(FileName);
- end
- else if not(ord(Letter) in [13,27,32,46]) then write(chr(7));
- if count = Pos('.',FileName) then count := count + 1;
- end else Dir := True;
- until (count = Maxcount + 1) or (ord(Letter) in [13,27,63]);
- if (ord(Letter) in [27,63]) or (count=1) then Exit := true else begin
- if Copy(Filename, Maxcount-2,1) = '-' then begin
- Filename := Copy(Filename, 1, Length(Filename)-4);
- Filename := Filename + '.FIL';
- end;
- repeat
- Delete(Filename,Pos('-',Filename),1);
- until Pos('-',Filename)=0;
- GotoXY(1,Line);
- Write(' ');
- GotoXY(1,Line);
- Write(Filename);
- end;
- end;
-
- procedure Printrow;
- begin
- Port[980]:=10; Port[981]:=8;
- Window(1,1,80,25);
- GotoXY(60,1);
- write(Row : 3);
- GotoXY(75,1);
- write(Column : 2);
- Window(1,2,80,23);
- GotoXY(Column, ScreenRow);
- end;
-
- procedure CapsCheck;
- var Caps : integer;
-
- begin
- Caps := Mem[$40:$18];
- if Caps = 64 then begin
- CapsMode := not CapsMode;
- Window(1,1,80,25);
- GotoXY(13,1);
- if CapsMode then write('Caps Lock') else write(Replicate(10,205));
- Repeat Caps := Mem[$40:$18] until Caps = 0;
- Window(1,2,80,23);
- GotoXY(Column, ScreenRow);
- end;
- end;
-
- procedure Menu(Title, Choice1, Choice2, Choice3, Choice4, Choice5 : TempString);
- begin
- Exit := false;
- While KeyPressed do Read(Kbd,ch);
- ClrScr;
- writeln(Title);
- writeln;
- writeln('1. ',Choice1);
- writeln('2. ',Choice2);
- writeln('3. ',Choice3);
- writeln('4. ',Choice4);
- writeln('5. ',Choice5);
- writeln;
- write('? ');
- GotoXY(1,10);
- write('Press Esc to exit');
- GotoXY(3,9);
- read(Kbd, Choice);
- If ord(Choice) = 27 then Exit := true else Val(Choice, Num, code);
- if (code>0) or (Num>5) or (Num<1) then Num := 0;
- end;
-
- procedure CommandWindow(Strg : TempString; x,y,x1,y1 : integer);
- begin
- if Dir = false then Fill_Buffer('I',x,y,x1,y1);
- Window(x,y,x1,y1);
- ClrScr;
- Window(1,2,80,23);
- GotoXY(x,y-1); Write(chr(213));
- Write(Replicate((x1-1)-x,205));
- Write(chr(184));
- for i:=y to y1-2 do
- begin
- GotoXY(x, i); Write(chr(179));
- GotoXY(x1, i); Write(chr(179));
- end;
- GotoXY(x, y1-1);
- Write(chr(212));
- Write(Replicate((x1-1)-x,205));
- Write(chr(190));
- Window(x+2,y+1,x1-2,y1-1);
- GotoXY(1,1);
- if Strg <> ' ' then begin
- write(Replicate(x1-x-4,223));
- GotoXY(1,2);
- write(Strg);
- GotoXY(1,3);
- write(Replicate(x1-x-4,220));
- end;
- end;
-
- procedure ClearScreen;
- begin
- CommandWindow(' ',28,6,52,18);
- ClrScr;
- GotoXY(1,3);
- write('Clear Memory, Erase Text?',chr(13),chr(10),chr(10));
- write('ARE YOU SURE? (Y/N) ');
- read(Kbd,Inkey);
- write(Inkey);
- if (Inkey = 'y') or (Inkey = 'Y') then begin
- TempWord := Replicate(79,32);
- for i := 1 to 500 do Words[i] := TempWord;
- Row := 1;
- ScreenRow := 1;
- Column := 1;
- MaxRow := 1;
- end
- else Exit := true;
- end;
-
- function GetKey(var secnum : boolean; var Inkey : char) : boolean;
- begin
- if KeyPressed then begin
- GetKey := true;
- dosrec.ax := $0800;
- msdos(dosrec);
- Inkey := chr(lo(dosrec.ax));
- KeyNum := ord(Inkey);
- Secnum := ord(Inkey) = 0;
- if Secnum then begin
- dosrec.ax := $0800;
- msdos(dosrec);
- Keynum := ord(chr(lo(dosrec.ax)));
- end
- else if ord(Inkey) <= 27 then Secnum := true else Secnum := false;
- end
- else begin
- Getkey := false;
- secnum := false;
- end;
- end;
-
- procedure InsertLine;
- begin
- if Temp1 <> 3333 then InsLine;
- for i := MaxRow + 1 downto Row do Words[i+1] := Words[i];
- Words[Row] := Replicate(79,32);
- MaxRow := MaxRow + 1;
- end;
-
- procedure ScrollUp;
- begin
- ScreenRow := 22;
- GotoXY(1,1);
- DelLine;
- GotoXY(1, ScreenRow);
- write(Words[Row]);
- end;
-
- procedure Enter;
- begin
- Row := Row + 1;
- Oops := Words[Row];
- ScreenRow := Screenrow + 1;
- if ScreenRow > 22 then ScrollUp;
- if InsertMode then begin
- GotoXY(Column, ScreenRow-1);
- ClrEol;
- Sound(450);
- Delay(20);
- NoSound;
- if Temp1 = 5555 then Column := Column + 1;
- GotoXY(1,ScreenRow);
- InsertLine;
- Words[Row] := Copy(Words[Row-1],Column,79-Column) +
- Replicate(79-(79-Column),32);
- Words[Row-1] := Copy(Words[Row-1],1,Column-1)+Replicate(79-Column,32);
- FuncEnd;
- if Temp1 = 5555 then Words[Row][Column] := Inkey;
- GotoXY(1,ScreenRow);
- TempWord := Replicate(79,32);
- if Words[Row] <> Tempword then Write(Words[Row]);
- end else Column := 1;
- if row > MaxRow then MaxRow := Row;
- GotoXY(Column, Screenrow);
- end;
-
- procedure WordWrap;
- var Mode : boolean;
-
- begin
- Column := 79;
- Temp1 := 5555;
- TempWord := Words[Row];
- Mode := InsertMode;
-
- repeat
- Column := Column - 1;
- until TempWord[Column] = chr(32);
- if Column < 2 then Column := 2;
- InsertMode := true;
- Enter;
- InsertMode := Mode;
- Temp1 := 1;
- Column := Column + 1;
- end;
-
- procedure Character;
- begin
- if Column = 79 then WordWrap else
- begin
- GotoXY(Column,ScreenRow);
- write(Inkey);
- Insert(Inkey, Words[Row], Column);
- if not Insertmode then Delete(Words[Row],Column + 1,1);
- Column := Column + 1;
- if Column = 70 then begin
- Sound(1010);
- Delay(10);
- NoSound;
- end;
- end;
- end;
-
- procedure DeleteLine;
- begin
- DelLine;
- GotoXY(1, 22);
- write(Words[Row+(23-ScreenRow)]);
- for i := Row to MaxRow + 1 do Words[i] := Words[i+1];
- MaxRow := MaxRow - 1;
- if Row > MaxRow then MaxRow := Row;
- end;
-
- procedure Del;
- begin
- if Column >= 79 then Column := 78;
- ch := Copy(Words[Row], Column, 1);
- Delete(Words[Row], Column, 1);
- Words[Row] := Words[Row] + ' ';
- Port[980]:=10; Port[981] := 8;
- GotoXY(Column, ScreenRow);
- TempWord := Copy(Words[Row],Column,79-Column);
- if ScreenRow = 22 then write(TempWord) else writeln(TempWord);
- end;
-
- procedure Backspace;
- begin
- if Column > 1 then begin
- Column := Column - 1;
- if Column < 79 then Del;
- end else begin
- i := Row;
- FuncEnd;
- Temp1 := Column-1;
- i := Row-1;
- FuncEnd;
- Temp2 := Column-1;
- if Temp1 + Temp2 <= 79 then begin
- Sound(200);
- Delay(20);
- NoSound;
- Words[Row-1] := Copy(Words[Row-1],1,Temp2) + Copy(Words[Row],1,Temp1) +
- Replicate(79-(Temp1+Temp2),32);
- Words[Row] := Replicate(79,32);
- GotoXY(1,ScreenRow-1);
- Writeln(Words[Row-1]);
- GotoXY(1,ScreenRow);
- ClrEol;
- DeleteLine;
- Row := Row - 1;
- Oops := Words[Row];
- ScreenRow := ScreenRow - 1;
- Column := Temp2 + 1;
- end;
- end;
- end;
-
- procedure CursorLeft;
- begin
- column := column - 1;
- if column < 1 then begin
- column := 79;
- if Row = 1 then Row := 1 else Row := Row - 1;
- Oops := Words[Row];
- if ScreenRow = 1 then ScreenRow := 1 else ScreenRow := ScreenRow - 1;
- end
- end;
-
- procedure CursorRight;
- begin
- column := column + 1;
- If Column > 79 then begin
- Column := 1;
- Row := Row + 1;
- Oops := Words[Row];
- if Row > MaxRow then MaxRow := Row;
- If ScreenRow < 22 then ScreenRow := ScreenRow + 1 else ScrollUp;
- end;
- end;
-
- procedure CursorUp;
- begin
- if row = 1 then Row_One := true else Row_One := false;
- row := row - 1;
- Oops := Words[Row];
- if row < 1 then row := 1;
- if (ScreenRow = 1) and not Row_One then begin
- GotoXY(1,1);
- InsLine;
- GotoXY(1,1);
- write(Words[Row]);
- end;
- ScreenRow := ScreenRow - 1;
- if ScreenRow < 1 then ScreenRow := 1;
- end;
-
- procedure CursorDown;
- begin
- row := row + 1;
- Oops := Words[Row];
- if row > MaxRow then MaxRow := Row;
- ScreenRow := ScreenRow + 1;
- if ScreenRow > 22 then ScrollUp;
- end;
-
- procedure DirGet (Func, Asciiz : TempString; var FileName : TempString;
- var Error : Integer; Option : Integer);
- var
- OurDTA : array [ 1..43 ] of byte; { Data Transfer Area buffer }
- CurDTAseg, { DTA segment before execution }
- CurDTAofs, { DTA offset " " }
- OurDTAseg, { DTA segment and offset set after }
- OurDTAofs : integer; { start of program }
-
- begin
- error := 0;
- If Func = 'FIRST' then begin
- Error := 0; {---------- Initialization processes ------------}
- For I := 1 to 43 do OurDTA[I]:=0; {Initialize our DTA Buffer}
- dosrec.ax := $2F00; { Save Current DTA pointer}
- Intr($21,dosrec); { to be restored later }
- CurDTASeg := dosrec.es;
- CurDTAOfs := dosrec.bx;
- error := dosrec.ax and $FF;
- if error = 0 then begin
- OurDTAseg := seg(OurDTA); {Point DOS to our }
- OurDTAofs := ofs(OurDTA); {DTA Buffer }
- dosrec.ax := $1A00;
- dosrec.ds := OurDTASeg;
- dosrec.dx := OurDTAOfs;
- Intr($21,dosrec);
- error := dosrec.ax and $FF;
- end;
- asciiz[length(asciiz)+1]:=chr(0); { Terminate name with hex00 }
- dosrec.ax := $4E00; { Get first directory entry }
- dosrec.ds := seg(Asciiz); { Point to the file mask }
- dosrec.dx := ofs(Asciiz);
- dosrec.dx := dosrec.dx + 1; { Point past string's length byte }
- dosrec.cx := Option;
- end
- else
- dosrec.ax := $4F00; {Get next directory entry}
- Intr($21,dosrec); { Execute MSDos call }
- error := dosrec.ax and $FF; { Get error return }
- I := 1;
- If error = 0 then
- Repeat { Get name from the DTA area }
- FileName[I]:=chr(mem[OurDTASeg:OurDTAOfs + 29 + I]);
- I := I + 1;
- Until (not (FileName[I - 1] in [' '..'~']));
- FileName[0]:=chr(I-1) { set string length because assigning }
- { by element does not set length }
- end;
-
- procedure PrintDir;
- var err,place : integer;
- firstname, nextnames : TempString;
-
- Begin
- ClrScr;
- DirGet('FIRST','????????.???'+chr(0),FIRSTNAME,err,8);
- writeln('Directory of A: Volume name is ',FIRSTNAME);
- writeln('Only Turbo Script files listed.',chr(13),chr(10));
- DirGet('FIRST','A:????????.FIL'+chr(0),Firstname,err,3);
- write(copy(Firstname,1,Pos('.',Firstname)-1));
- place := 13;
- repeat
- if Place = 49 then begin
- Writeln;
- Place := 1;
- end;
- GotoXY(Place, WhereY);
- DirGet('NEXT','A:????????.FIL'+chr(0),Nextnames,err,3);
- Nextnames := Copy(Nextnames,1,pos('.',Nextnames)-1);
- Write(Nextnames);
- Place := Place + 12;
- until err<>0;
- dosrec.ax := $3600;
- dosrec.dx := 0;
- Intr($21, dosrec);
- writeln;
- writeln(' ',dosrec.bx,'k bytes free',chr(13),chr(10));
- if Inum = 3333 then begin
- writeln('Press any key to continue...');
- read(Kbd, Choice);
- end;
- end;
-
- function Exist(Name : TempString) : boolean;
- begin
- Assign(TextFile, Name);
- {$I-}
- Reset(TextFile);
- {$I+}
- Exist := (IOresult = 0);
- end;
-
- procedure Warning;
- begin
- ClrScr;
- Writeln(chr(7),'<<<<<<<<<<>>>>>>>>>> ');
- writeln('That file already');
- writeln(' exists.');
- writeln;
- writeln('Replace it (Y/N)?');
- writeln;
- writeln('<<<<<<<<<<>>>>>>>>>>');
- GotoXY(19,6);
- Read(Kbd, Choice);
- GotoXY(19,6);
- write(Choice);
- if (Choice = 'n') or (Choice = 'N') then Exit := true;
- end;
-
- overlay procedure Savefile;
- begin
- Dir := false;
- CommandWindow(' Save File',28,6,52,18);
- GotoXY(1,5);
- writeln('Enter File Name:');
- Data_In(8, Filename);
- if Dir = True then begin
- Exit := false;
- Fill_Buffer('O',28,6,52,18);
- Fill_Buffer('I',2,3,78,19);
- CommandWindow(' ',2,3,52,19);
- PrintDir;
- CommandWindow(' Save File',54,6,78,18);
- GotoXY(1,5);
- Writeln('Enter File Name:');
- Data_In(8, Filename);
- end;
- if Exit = false then begin
- if Exist(FileName) = true then Warning;
- if Exit = false then begin
- Rewrite(TextFile);
- for i := 1 to MaxRow do Writeln(TextFile, Words[i]);
- Close(TextFile);
- end;
- end;
- if Dir=false then Fill_Buffer('O',28,6,52,18) else Fill_Buffer('O',2,3,78,19);
- end;
-
- overlay procedure Loadfile(Title : TempString; Start : integer);
- begin
- Dir := false;
- Temp1 := 3333;
- Temp2 := Row;
- CommandWindow(' '+Title+' File',28,6,52,18);
- GotoXY(1,5);
- Writeln('Enter File Name:');
- Data_In(8, Filename);
- if Dir = True then begin
- Exit := false;
- Fill_Buffer('O',28,6,52,18);
- Fill_Buffer('I',2,3,78,19);
- CommandWindow(' ',2,3,52,19);
- PrintDir;
- CommandWindow(' '+Title+' File',54,6,78,18);
- GotoXY(1,5);
- Writeln('Enter File Name:');
- Data_In(8, Filename);
- end;
- if Exit = false then if Exist(FileName)=true then begin
- if Title='Load' then ClearScreen;
- if Exit = false then begin
- Row := Start;
- While EOF(Textfile) = false do begin
- if Title = 'Merge' then InsertLine;
- Readln(TextFile, Words[Row]);
- if Length(Words[Row]) >= 80 then Words[Row] := Copy(Words[Row], 1, 79);
- if Title = 'Load' then MaxRow := MaxRow + 1;
- Row := Row + 1;
- end;
- Temp1 := 1;
- Close(TextFile);
- Window(1,2,80,23);
- ClrScr;
- GotoXY(1,1);
- if Title = 'Load' then begin
- PrintWords(1);
- Row := 1;
- end else begin
- Row := Temp2;
- PrintWords(Row-ScreenRow+1);
- end;
- Oops := Words[Row];
- end;
- end
- else if Exit = False then begin
- ClrScr;
- writeln(chr(7));
- writeln('File does not exist');
- Delay(1000);
- Exit := true;
- Row := Temp2;
- end;
- if Exit = true then begin
- if Dir=false then Fill_Buffer('O',28,6,52,18) else Fill_Buffer('O',2,3,78,19);
- end;
- end;
-
- overlay procedure PrintFile;
- var Linespaces,RowNum,j,LineNum,Page : integer;
- UnderMode, ItalicMode, BoldMode, PageNums : boolean;
-
- procedure SetMargins;
- var LeftMarg, RightMarg : integer;
-
- begin
- Menu('Select Top Margin:',' 1"',' 1 1/2"',' 2"',' 2 1/2"',' None');
- if Num in [1..4] then begin
- Temp1 := (Num + 1)*3;
- ClrScr;
- writeln('Set Horizontal Margins (Y/N)');
- read(Kbd, Choice);
- if (Choice = 'Y') or (Choice = 'y') then begin
- writeln;
- writeln('Enter Left margin:');
- Read(LeftMarg);
- writeln;
- writeln('Enter Right margin:');
- Read(RightMarg);
- Typeset := Typeset + chr(27) + chr(77) + chr(LeftMarg) +
- chr(27) + chr(81) + chr(RightMarg);
- end;
- end else Temp1 := 1;
- end;
-
- procedure PrintTitle;
- var Titlename : TempString;
- Spacing : integer;
-
- begin
- Dir := true;
- CommandWindow(' Title',28,6,52,18);
- Dir := false;
- GotoXY(1,5);
- writeln('Enter title:');
- read(Titlename);
- Write(Lst, chr(27), chr(71), chr(27), chr(69), chr(27), chr(14));
- Spacing := 20 - Length(Titlename) div 2;
- Spacing := Spacing + Length(Titlename);
- writeln(Lst, Titlename : Spacing);
- writeln(Lst, chr(27), chr(64), Typeset);
- ClrScr;
- GotoXY(1,3);
- TextColor(White + Blink);
- writeln('Printing...');
- TextColor(White);
- writeln;
- writeln('<< Press any key >>');
- writeln('<< to abort. >>');
- end;
-
- procedure Script(Style : integer);
- begin
- Write(Lst, chr(27), chr(83), chr(Style));
- Index := Index + 1;
- repeat
- Write(Lst, TempWord[Index]);
- Index := Index + 1;
- until not(TempWord[Index] in ['0'..'9','-']) = true;
- write(Lst, chr(27), chr(84));
- end;
-
- procedure Fonts(var Mode : boolean; Num : integer);
- begin
- Mode := Not Mode;
- if Num = 45 then begin
- if Mode = true then Write(Lst, chr(27),chr(Num),chr(1)) else
- Write(Lst, chr(27), chr(Num), chr(0));
- end else if Mode = true then Write(Lst, chr(27), chr(Num)) else
- Write(Lst, chr(27), chr(Num+1));
- end;
-
-
- begin { Print File }
- UnderMode := false;
- Italicmode := false;
- Boldmode := false;
- PageNums := false;
- Temp2 := Column;
- CommandWindow(' Print file',28,6,52,18);
- Typeset := chr(27)+chr(64);
- GotoXY(1,7);
- writeln('Press any key...');
- repeat until KeyPressed;
- repeat
- Menu('Choose print style:', ' Elite', ' Boldface', ' Italic', ' Compressed', ' Continue');
- Case Num of
- 1 : Typeset := Concat(Typeset,chr(27),chr(66),chr(2),
- chr(27),chr(77),chr(11));
- 2 : Typeset := Concat(Typeset,chr(27),chr(71));
- 3 : Typeset := Concat(Typeset,chr(27),chr(52));
- 4 : Typeset := Concat(Typeset,chr(15),chr(27),chr(77),chr(32));
- 5 :;
- else
- if Exit = false then write(chr(7));
- end;
- if Num in [1..4] then begin
- Sound(300);
- Delay(50);
- NoSound;
- write(' Done.');
- Delay(300);
- end;
- until (Num = 5) or (Exit = true);
- if Exit = false then begin
- SetMargins;
- ClrScr;
- writeln('Set line spacing:');
- writeln;
- writeln('1. Single');
- writeln('2. Double');
- writeln('3. Triple');
- writeln;
- read(Kbd, Choice);
- Val(Choice, Num, code);
- if (Num in [1..3]) and (code = 0) then Linespaces := Num;
- writeln;
- Write('Do you want Page Numbers? (Y/N): ');
- read(Kbd, Choice);
- if (Choice = 'Y') or (Choice = 'y') then PageNums := true;
- While KeyPressed do Read(Kbd,Choice);
- ClrScr;
- Writeln('Scroll paper to perf');
- Writeln('and press any key to');
- writeln('print, or Esc to');
- writeln('exit');
- read(Kbd, Choice);
- if ord(Choice) <> 27 then begin
- ClrScr;
- GotoXY(1,3);
- TextColor(White + Blink);
- writeln('Printing...');
- TextColor(White);
- writeln;
- writeln('<< Press any key >>');
- writeln('<< to abort. >>');
- writeln(Lst, Typeset);
- RowNum:= 0;
- LineNum := 0;
- Page := 1;
- for j := 1 to Temp1 do write(Lst,chr(10));
- While (not KeyPressed) and (RowNum < MaxRow + 1) do begin
- TempWord := Replicate(79,32);
- RowNum := RowNum + 1;
- LineNum := LineNum + LineSpaces;
- if Copy(Words[RowNum],1,5) = 'Title' then PrintTitle
- else begin
- if Words[RowNum] <> TempWord then begin
- i := RowNum;
- FuncEnd;
- TempWord := Copy(Words[RowNum],1,Column);
- Index := 0;
- repeat
- Index := Index + 1;
- case TempWord[Index] of
- '\' : Fonts(UnderMode,45);
- '~' : Script(0);
- '|' : Script(1);
- '√' : Fonts(ItalicMode,52);
- '■' : Fonts(BoldMode,71);
- else Write(Lst, TempWord[Index]);
- end;
- until Index >= Length(TempWord);
- Write(Lst, chr(13));
- end;
- for j := 1 to Linespaces do write(Lst, chr(10));
- end;
- if (LineNum = (66-Temp1*2)) and (Temp1 > 2) then begin
- LineNum := 0;
- Page := Page + 1;
- for j := 1 to Temp1 do write(Lst, chr(10));
- if PageNums then begin
- write(Lst, chr(10),chr(10),Replicate(73,32),'Page ',Page);
- for j := 1 to Temp1-2 do write(Lst, chr(10));
- end else for j := 1 to Temp1 do write(Lst, chr(10));
- end;
- end;
- if KeyPressed then Read(Kbd, Choice);
- end;
- end;
- Column := Temp2;
- GotoXY(1,3);
- Writeln(' ');
- Fill_Buffer('O',28,6,52,18);
- end;
-
- overlay procedure Menu_S_R;
-
- procedure Search;
- var SearchString, Temp : TempString;
- Pointer, Position, Line, Len : integer;
-
- begin
- Line := 2;
- SearchString := '';
- CommandWindow(' Search',28,6,52,18);
- GotoXY(1, 5);
- writeln('Enter String: ');
- writeln;
- write('? ');
- read(SearchString);
- Len := Length(SearchString);
- Window(1,2,80,23);
- ClrScr;
- for i := 1 to MaxRow do begin
- Pointer := Pos(SearchString, Words[i]);
- if (Exit = false) and (Pointer > 0) then begin
- Temp := Words[i];
- Position := Pointer;
- GotoXY(1, Line);
- LowVideo;
- write(Temp);
- NormVideo;
- While Pointer > 0 do begin
- GotoXY(Position, Line);
- write(Copy(Temp, Pointer, Len));
- Temp := Copy(Temp, Pointer + Len + 1,
- 80 - Pointer + Len + 1);
- Pointer := Pos(SearchString, Temp);
- Position := Position + Pointer + Len;
- end;
- writeln;
- Line := Line + 1;
- if Line = 20 then begin
- GotoXY(1, 22);
- write('Press any key to continue or Esc to exit ...');
- read(Kbd, Choice);
- if ord(Choice) = 27 then Exit := true else begin
- ClrScr;
- line := 2;
- end;
- end;
- if line > 2 then begin
- read(Kbd, Choice);
- if ord(Choice) = 27 then Exit := true;
- end;
- end;
- end;
- writeln(chr(13),chr(10),chr(10));
- writeln('End of search');
- repeat until Keypressed;
- end;
-
- procedure Replace;
- var SearchString, Replacement : TempString;
- Pointer, Line, Len : integer;
-
- begin
- Line := 2;
- SearchString := '';
- Replacement := '';
- CommandWindow(' Replace',28,6,52,18);
- GotoXY(1, 5);
- writeln('Enter String: ');
- writeln;
- write('? ');
- read( SearchString);
- writeln;
- writeln('Enter Replacement:');
- writeln;
- write('? ');
- read( Replacement);
- Len := Length(Replacement);
- Window(1,2,80,23);
- ClrScr;
- for i := 1 to MaxRow do begin
- Pointer := Pos(SearchString, Words[i]);
- if (Pointer > 0) and (Exit = false) then begin
- GotoXY(1, Line);
- LowVideo;
- write(Words[i]);
- NormVideo;
- GotoXY(Pointer, Line);
- write(Copy(Words[i], Pointer, Length(SearchString)));
- GotoXY(1,22);
- write('Replace Y/N');
- read(Kbd, Choice);
- if ord(Choice) = 27 then Exit := true else if (Choice = 'Y') or
- (Choice = 'y') then begin
- Words[i] := Copy(Words[i],1,Pointer-1) + Replacement +
- Copy(Words[i], Pointer + Length(SearchString), 80-Len+1);
- GotoXY(1, Line);
- LowVideo;
- write(Words[i]);
- NormVideo;
- GotoXY(Pointer, Line);
- write(Copy(Words[i], Pointer, Len));
- end
- else begin
- GotoXY(80, Line);
- write('N');
- end;
- Line := Line + 1;
- if Line = 20 then begin
- writeln('Press any key to continue or Esc to exit ...');
- read(Kbd, Choice);
- if ord(Choice) = 27 then Exit := true else begin
- ClrScr;
- line := 2;
- end;
- end;
- end;
- end;
- writeln;
- write('End of replace');
- repeat until Keypressed;
- end;
-
- begin {Menu_S_R}
- CommandWindow(' Search / Replace',28,6,52,18);
- Exit := false;
- GotoXY(1,5);
- Writeln('Enter Choice: ');
- writeln;
- writeln('1. Search');
- writeln('2. Replace');
- writeln;
- write('? ');
- GotoXY(1,10);
- write('Press Esc to exit');
- read(Kbd, Choice);
- if ord(Choice) = 27 then Exit := true else Val(Choice, Num, code);
- if (Exit = false) and (Num in [1,2]) then
- case Num of
- 1 : Search;
- 2 : Replace;
- end
- else begin
- if Exit = false then write(chr(7));
- Fill_Buffer('O',28,6,52,18);
- Exit := true;
- end;
- if Exit = false then begin
- ClrScr;
- GotoXY(1,1);
- PrintWords(Row-ScreenRow+1);
- end;
- end;
-
- overlay procedure DosMenu;
-
- procedure DelFile;
- begin
- ClrScr;
- Dir := false;
- writeln('Enter file to Delete:');
- Data_In(4, FileName);
- if Dir = True then begin
- Exit := false;
- Fill_Buffer('O',28,6,52,18);
- Fill_Buffer('I',2,3,78,19);
- CommandWindow(' ',2,3,52,19);
- PrintDir;
- CommandWindow(' ',54,6,78,18);
- Writeln('Enter File Name:');
- Data_In(4, Filename);
- end;
- if (Exist(FileName) = true) and (Exit=false) then begin
- Erase(Textfile);
- GotoXY(1,6);
- writeln('File deleted');
- Delay(1000);
- end
- else begin
- GotoXY(1,6);
- if Exit=false then writeln(chr(7),'File does not exist');
- Delay(1000);
- end;
- end;
-
- procedure RenFile;
- var OldName, NewName : TempString;
-
- begin
- ClrScr;
- Writeln('Enter old file name:');
- Data_In(4, OldName);
- if Dir = True then begin
- Exit := false;
- Fill_Buffer('O',28,6,52,18);
- Fill_Buffer('I',2,3,78,19);
- CommandWindow(' ',2,3,52,19);
- PrintDir;
- CommandWindow(' ',54,6,78,18);
- Writeln('Enter old File Name:');
- Data_In(4, OldName);
- end;
- if (Exist(OldName) = true) and (Exit=false) then begin
- Close(Textfile);
- ClrScr;
- writeln('Enter new name:');
- Data_In(4, NewName);
- if (Exist(NewName) = false) and (Exit=false) then begin
- Close(Textfile);
- Assign(Textfile, OldName);
- Rename(Textfile, NewName);
- Close(Textfile);
- end
- else begin
- GotoXY(1,8);
- if Exit=false then write(chr(7),'New file already exists');
- Delay(1000);
- end;
- end
- else begin
- GotoXY(1,8);
- if Exit=false then write(chr(7),'File does not exist');
- Delay(1000);
- end;
- end;
-
- procedure Copyfile;
- var Firstname, SecondName : TempString;
- SecondFile : Text;
- There : boolean;
-
- begin
- ClrScr;
- Writeln('Enter source file:');
- Data_In(4, Firstname);
- if Dir = True then begin
- Exit := false;
- Fill_Buffer('O',28,6,52,18);
- Fill_Buffer('I',2,3,78,19);
- CommandWindow(' ',2,3,52,19);
- PrintDir;
- CommandWindow(' ',54,6,78,18);
- Writeln('Enter Source File:');
- Data_In(4, FirstName);
- end;
- if (Exist(FirstName) = true) and (Exit=false) then begin
- ClrScr;
- writeln('Enter Target File:');
- Data_In(4, SecondName);
- Assign(SecondFile, SecondName);
- {$I-}
- Reset(SecondFile);
- {$I+}
- There := (IOresult = 0);
- if (There = false) and (Exit=False) then begin
- Close(SecondFile);
- Rewrite(SecondFile);
- writeln;
- writeln;
- writeln('Copying......');
- while EOF(Textfile) = false do begin
- Readln(Textfile, TempWord);
- Writeln(SecondFile, TempWord);
- TempWord := '';
- end;
- Close(Textfile);
- Close(SecondFile);
- end
- else begin
- GotoXY(1,8);
- if Exit=false then write(chr(7),'New file already exists');
- Delay(1000);
- end;
- end
- else begin
- GotoXY(1,8);
- if Exit=false then write(chr(7),'File does not exist');
- Delay(1000);
- end;
- end;
-
- begin {DosMenu}
- Inum := 0;
- Dir := false;
- CommandWindow(' ',28,6,52,18);
- Menu(' DOS Menu',' Directory',' Delete',' Rename',' Copy file',
- ' Exit to DOS');
- if Exit = false then begin
- case Num of
- 1 : begin
- Fill_Buffer('O',28,6,52,18);
- CommandWindow(' ',2,3,52,19);
- Inum := 3333;
- PrintDir;
- Fill_Buffer('O',2,3,52,19);
- end;
- 2 : DelFile;
- 3 : RenFile;
- 4 : CopyFile;
- 5 : begin
- ClrScr;
- GotoXY(1,4);
- Writeln('Exit Turbo Script,');
- Writeln;
- Write('Erase memory (Y/N)? ');
- Read(Kbd, Choice);
- if (Choice = 'Y') or (Choice = 'y') then NumEnd := 9999
- else NumEnd := 0;
- end;
- else write(chr(7));
- end; { case }
- end;
- if (Num <> 1) and (Num <> 5) then begin
- if Dir = false then Fill_Buffer('O',28,6,52,18) else
- Fill_Buffer('O',2,3,78,19);
- end;
- end;
-
- overlay procedure Initialize;
- const
- Digits: array[1..10] of char = ('1','2','3','4','5','6','7','8','9','0');
- Positions: array[1..10] of integer = (1,8,18,25,33,39,49,59,67,74);
-
- begin
- CrtInit;
- ClrScr;
- Row := 1;
- Column := 1;
- ScreenRow := 1;
- MaxRow := 1;
- Window(1,1,80,25);
- GotoXY(1,1);
- Write(Replicate(80,205));
- GotoXY(1,24);
- Write(Replicate(80,196));
- GotoXY(34,1);
- Write('Turbo Script');
- GotoXY(54,1);
- writeln('Row = ',Row : 3,' Column = ',Column : 2);
- GotoXY(1,25);
- LowVideo;
- write('Help ':6,'Ser/Rep ':10,'Tabs ':7,'Title ':8,'DOS ':6);
- write('InsLine ':10,'DelLine ':10,'Print ':8,'Load ':7,'Save ':7);
- NormVideo;
- for i := 1 to 10 do begin
- GotoXY(Positions[i], 25);
- write(Digits[i]);
- end;
- Window(1,2,80,23);
- TempWord := Replicate(79,32);
- for i:=1 to 500 do Words[i] := TempWord;
- TempWord := '';
- Insertmode := false;
- Dir := false;
- CapsMode := false;
- Mem[$40:$17] := 0;
- Exit := false;
- NumEnd := 1;
- for i := 1 to 80 do Tabset[i] := false;
- Tabset[6] := true;
- Tabset[40] := true;
- end;
-
- procedure TabMenu;
- begin
- Window(1,1,80,25);
- GotoXY(1,1);
- write('Tabs '); LowVideo; Write ('- ['); NormVideo; write('S');
- LowVideo; Write(']et, ['); NormVideo; write('C'); LowVideo; write(']lear, [');
- NormVideo; Write('P'); LowVideo; Write(']urge: '); NormVideo;
- read(Kbd, Choice);
- if Choice in ['s','S'] then Tabset[Column] := true;
- if Choice in ['c','C'] then Tabset[Column] := false;
- if Choice in ['p','P'] then for i := 1 to 79 do Tabset[i] := false;
- if not(Choice in ['s','c','p','S','C','P']) then write(chr(7));
- GotoXY(1,1);
- write(Replicate(33,205));
- Window(1,2,80,25);
- CapsMode := Not CapsMode;
- CapsCheck;
- end;
-
- procedure PrevWord;
- begin
- TempWord := Words[Row];
- Index := Column;
- repeat
- Index := Index - 1;
- ch := TempWord[Index];
- until ch <> ' ';
- repeat
- Index := Index - 1;
- ch := TempWord[Index];
- until (ch = ' ') or (Index < 1);
- Column := Index + 1;
- if Column < 1 then Column := 1;
- end;
-
- procedure NextWord;
- begin
- TempWord := Words[Row];
- Index := Column;
- repeat
- Index := Index + 1;
- ch := TempWord[Index];
- until (ch = ' ') or (Index > 79);
- repeat
- Index := Index + 1;
- ch := TempWord[Index];
- until ch <> ' ';
- Column := Index;
- if Column > 79 then Column := 79;
- end;
-
- procedure Help;
- begin
- Assign(TextFile, 'HELP.HLP');
- Reset(TextFile);
- While EOF(Textfile) = false do begin
- ClrScr;
- GotoXY(1,1);
- Index := 0;
- NormVideo;
- repeat
- Readln(TextFile, TempWord);
- Index := Index + 1;
- writeln(TempWord);
- until (Index = 20) or (EOF(TextFile)=true);
- LowVideo;
- GotoXY(1,22);
- Write(' < Press');
- NormVideo;
- Write(' ENTER ');
- LowVideo;
- Write('to continue >');
- read(Kbd, Choice);
- end;
- Close(TextFile);
- NormVideo;
- ClrScr;
- GotoXY(1,1);
- PrintWords(Row-ScreenRow+1);
- end;
-
- procedure Ascii;
- var Ascnum, Repeats, r : integer;
-
- begin
- Window(1,1,80,25);
- GotoXY(1,1);
- Write('Enter ASCII code number: --- ');
- GotoXY(26,1);
- Readln(Ascnum);
- GotoXY(1,1);
- Write('Enter number of repeats: -- ');
- GotoXY(26,1);
- Readln(Repeats);
- if not(Repeats in [1..79]) then Repeats := 1;
- GotoXY(1,1);
- Write(Replicate(30,205));
- If Ascnum < 255 then begin
- Window(1,2,80,23);
- for r := 1 to Repeats do begin
- GotoXY(Column,ScreenRow);
- Inkey := chr(Ascnum);
- Character;
- end;
- end
- else write(chr(7));
- CapsMode := not CapsMode;
- CapsCheck;
- Window(1,2,80,23);
- end;
-
- procedure MemoryFilled;
- begin
- CommandWindow(' ',28,6,52,18);
- GotoXY(1,2);
- Writeln(chr(7),'You have used up all');
- Writeln('Available memory in');
- Writeln('Turbo Script. Please');
- Writeln('save your file now');
- Writeln('and continue.');
- Delay(3000);
- SaveFile;
- TempWord := Replicate(79,32);
- for i:=1 to 500 do Words[i]:=TempWord;
- ClrScr;
- Row := 1; ScreenRow := 1;
- Column := 1;
- end;
-
- procedure EndFile;
- begin
- Row := MaxRow + 1;
- Oops := Words[Row];
- ScreenRow := 12;
- Column := 1;
- Temp1 := Row-11;
- GotoXY(1,1);
- TempWord := Replicate(79,32);
- PrintWords(Temp1);
- end;
-
- procedure HandleFunc;
- begin
- case Keynum of
- 8 : Backspace;
- 9 : begin
- if Column < 79 then begin
- repeat
- Column := Column + 1;
- until (Tabset[Column] = true) or (Column = 79);
- end;
- end;
- 13 : Enter;
- 15 : begin
- if Column > 1 then begin
- repeat
- Column := Column - 1;
- until (Tabset[Column] = true) or (Column = 1);
- end;
- end;
- 22 : begin
- Words[Row] := Oops;
- GotoXY(1, ScreenRow);
- write(Words[Row]);
- end;
- 23 : begin
- Inkey := chr(251);
- Character;
- end;
- 27 : begin
- Column := 1;
- GotoXY(1, WhereY);
- ClrEol;
- Words[Row] := Replicate(79,32);
- end;
- 30 : Ascii;
- 48 : begin
- Inkey := chr(254);
- Character;
- end;
- 50 : LoadFile('Merge',Row);
- 59 : Help;
- 60 : Menu_S_R;
- 61 : TabMenu;
- 62 : begin
- Words[Row] := 'Title' + Replicate(74,32);
- GotoXY(1, ScreenRow);
- Write(Words[Row]);
- Enter;
- end;
- 63 : DosMenu;
- 64 : Insertline;
- 65 : Deleteline;
- 66 : PrintFile;
- 67 : Loadfile('Load',1);
- 68 : Savefile;
- 71 : Column := 1;
- 72 : CursorUp;
- 73 : begin
- Row := Row - 21;
- if Row < 1 then Row := 1;
- if Row-ScreenRow < 1 then ScreenRow := Row;
- PrintWords(Row-ScreenRow+1);
- Oops := Words[Row];
- end;
- 75 : CursorLeft;
- 77 : CursorRight;
- 79 : begin
- i := Row;
- FuncEnd;
- end;
- 80 : CursorDown;
- 81 : begin
- if Row + 21 < 500 then begin
- Row := Row + 21;
- Oops := Words[Row];
- PrintWords(Row-ScreenRow+1);
- end;
- end;
- 82 : if Insertmode then Insertmode := false
- else Insertmode := true;
- 83 : Del;
- 115 : PrevWord;
- 116 : NextWord;
- 117 : begin
- ClrEol;
- Words[Row] := Copy(Words[Row], 1, Column-1) + Replicate(79-Column+1, 32);
- end;
- 118 : EndFile;
- 119 : begin
- ClearScreen;
- Fill_Buffer('O',28,6,52,18);
- if Exit = false then begin
- ClrScr;
- ScreenRow := 1;
- end;
- end;
- 132 : begin
- GotoXY(1,1);
- if Row > ScreenRow then PrintWords(1);
- Row := 1;
- Column := 1;
- ScreenRow := 1;
- end;
- else
- Sound(200);
- Delay(300);
- NoSound;
- end;
- end;
-
- begin
- Initialize;
- PrintRow;
- repeat
- Secnum := false;
- if Getkey(Secnum, Inkey) then begin
- if Secnum then HandleFunc else Character;
- PrintRow;
- Exit := false;
- if Length(Words[Row]) > 79 then Words[Row] := Copy(Words[Row],1,79);
- if Insertmode then begin
- Port[980]:=10; Port[981]:=8;
- GotoXY(Column, ScreenRow);
- TempWord := Copy(Words[Row],Column,79-Column);
- if ScreenRow = 22 then write(TempWord) else writeln(TempWord);
- end;
- GotoXY(Column , ScreenRow);
- end;
- if Row > 500 then MemoryFilled;
- CapsCheck;
- Port[980]:=10;
- if InsertMode then Port[981]:=4 else Port[981]:=7;
- Port[980]:=11; Port[981]:=7;
- until NumEnd = 9999;
- Window(1,1,80,25);
- ClrScr;
- end.