Category : Pascal Source Code
Archive   : TMULTASK.ZIP
Filename : KEYINPUT.PAS

 
Output of file : KEYINPUT.PAS contained in archive : TMULTASK.ZIP
{File: KEYINPUT.PAS ===================================================

This file contains all of the routines used in interpreting and
responding to keyboard input for the MultiTaskingDemo program.

=======================================================================}

{Procedure: MoveCursor =================================================
Author: E.T.Burleyson Last update: 28 Sept 87

This procedure moves the cursor a specified number of character
positions -- a positive number moves the cursor right/down, and a
negative number moves it left/up. All movements wrap. Sort of. }

Procedure MoveCursor(
delta: integer {number of chars to move cursor}
);

{======================================================================}
const
FirstPos = 81; {row2, col1}
LastPos = 1920; {row24, col80}

var
CursorPos: integer; {for linear accessing}
row: integer;
col: integer;

begin {MoveCursor}
CursorPos := ((WhereY-1)*80)+WhereX+delta;
if CursorPos > LastPos then CursorPos := FirstPos;
if CursorPos < FirstPos then CursorPos := LastPos;
row:=CursorPos div 80;
if CursorPos <> (row * 80) then begin
col:=CursorPos-(row * 80);
row:=row+1;
end {then}
else begin
col:=80;
end; {if}
GotoXY(Col,Row);
end; {MoveCursor}


{Procedure: ProcessKeyChar =============================================
Author: E.T.Burleyson Last Update: 28 Sept 87

This procedure will read one character from the keyboard if it is
being pressed at the time of the procedure call and then responds
appropriately to it. }

Procedure ProcessKeyChar;

{===================================================================}
var
ch : char; {this is the character read from the keyboard}
i : integer; {loop control}

begin {ProcessKeyChar}
PutNotice(' Press for help',0,0);
ClearScreen;
GotoXY(12,12);
writeln('Arrow keys move the cursor (watch line 25 as it moves)');
GotoXY(12,14);
writeln('Press to see a sample notice');
GotoXY(12,16);
writeln('Press to exit this program');
repeat
if not keypressed then begin
yield; {allow another task to run. Each task must give up
control by Yielding or Pausing every once in a while. }
end {then}
else begin
read(kbd,ch);
if (ch = esc) and keypressed then begin {if this is a function}
read(kbd,ch);
case ch of

AltN : begin
PutNotice(' This will stay up for about 4 seconds',ErrorColor,4);
end; {AltN}

AltH : begin
ClearScreen;
PutNotice(' Not much help, is it? ',0,0);
GotoXY(12,12);
writeln('Press to exit help');
end; {AltH}

AltX : terminate; {eXit the program}

LArr : MoveCursor(-1);

RArr : MoveCursor(+1);

UpArr : MoveCursor(-80);

DnArr : MoveCursor(+80);

else begin
sound(3000);
delay(10);
nosound;
end; {else}
end; {case}
end {then}
else begin {not a function key}
case ch of

Esc: begin {Esc}
PutNotice(' Press for help',0,0);
ClearScreen;
GotoXY(12,12);
writeln('Arrow keys move the cursor (watch line 25 as it moves)');
GotoXY(12,14);
writeln('Press to see a sample notice');
GotoXY(12,16);
writeln('Press to exit this program');
end; {Esc}

else begin
sound(3000);
delay(10);
nosound;
end; {else}

end; {case}
end; {if}
end; {if}
until false; {repeat forever}
end; {ProcessKeyChar}


  3 Responses to “Category : Pascal Source Code
Archive   : TMULTASK.ZIP
Filename : KEYINPUT.PAS

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/