home *** CD-ROM | disk | FTP | other *** search
- {********************************************
- * Part 2 of Turbo Script version 4.0 *
- ********************************************}
-
- 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 EndColumn 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(18,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;
- dosrec.ax := $2C00; {Check time}
- MsDos(dosrec);
- Window(1,1,80,25);
- if Hi(dosrec.cx) <> Hour then begin
- GotoXY(3,1);
- Hour := Hi(dosrec.cx);
- if Hour > 12 then begin
- pm := true;
- if Hour-12 < 10 then Write('0',Hour-12:1,':') else Write(Hour-12:2,':');
- end else begin
- pm := false;
- if Hour < 10 then Write('0',Hour:1,':') else Write(Hour:2,':');
- end;
- GotoXY(11,1);
- if pm then Write(' p') else Write(' a');
- end;
- if Lo(dosrec.cx) <> Min then begin
- Min := Lo(dosrec.cx);
- GotoXY(6,1);
- if Min < 10 then Write('0',Min:1,':') else Write(Min:2,':');
- end;
- if Hi(dosrec.dx) <> Sec then begin
- Sec := Hi(dosrec.dx);
- GotoXY(9,1);
- If Sec < 10 then Write('0',Sec:1) else Write(Sec:2);
- end;
- Window(1,2,80,23);
- Temp1 := 1;
- 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);
- if Choice5 <> ' ' then 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,EndColumn-Column) +
- Replicate(EndColumn-(EndColumn-Column),32);
- Words[Row-1] := Copy(Words[Row-1],1,Column-1)+Replicate(EndColumn-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 := EndColumn;
- 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 = EndColumn 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 = EndColumn-8 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 >= EndColumn then Column := EndColumn-1;
- 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,EndColumn-Column);
- Write(TempWord);
- end;
-
- procedure Backspace;
- begin
- if Column > 1 then begin
- Column := Column - 1;
- if Column < EndColumn then Del;
- end else if Row > 1 then begin
- i := Row;
- FuncEnd;
- Temp1 := Column-1;
- i := Row-1;
- FuncEnd;
- Temp2 := Column-1;
- if Temp1 + Temp2 <= EndColumn then begin
- Sound(200);
- Delay(20);
- NoSound;
- Words[Row-1] := Copy(Words[Row-1],1,Temp2) + Copy(Words[Row],1,Temp1) +
- Replicate(EndColumn-(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 := EndColumn;
- if Row = 1 then Row := 1 else Row := Row - 1;
- Oops := Words[Row];
- if ScreenRow > 1 then ScreenRow := ScreenRow - 1;
- end
- end;
-
- procedure CursorRight;
- begin
- column := column + 1;
- If Column > EndColumn 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
- row := row - 1;
- Oops := Words[Row];
- if row < 1 then row := 1;
- if (ScreenRow = 1) and (Row > 1) then begin
- GotoXY(1,1);
- InsLine;
- GotoXY(1,1);
- write(Words[Row]);
- end;
- if ScreenRow > 1 then ScreenRow := 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;