home *** CD-ROM | disk | FTP | other *** search
- Program Buffered_Keyboard_Routine;
-
- { This Routine Calls DOS when a key is pressed to get a character. }
- { This allows full access to the extended key codes. Turbo normally }
- { Replaces the Nul ASCII code of 0 with an esc. This makes the use }
- { of the Esc key at the same time as the extended keys impossible. }
- { The Demo with the routine Beeps every so often when a character }
- { has not been typed. Extended characters are printed in highlight. }
- { Written by: Kevin Bales Atlanta,Georgia 404-321-3841 }
- { ***NOTE: The DOS routine used has the side effect of having Ctrl-S }
- { and Ctrl-C having the same effects as in DOS. Ctrl-S }
- { Pauses, and Ctrl-C Interupts like a Ctrl-Break . }
-
- Var
- Ch: Char;
- Extended: Boolean;
- Count: Integer;
-
- Procedure GetChar(VAR Ch: Char; VAR Extended: Boolean);
- { This Procedure acts simliar to the BASIC "Inkey$" command. }
- { If no Character is in the Keyboard buffer, then Ch is set }
- { to ASCII code 0. If the character in the buffer is a char }
- { with an extended scan code, then Extended is set to true, }
- { and Ch is equal to the characters scan code. }
- Type
- Registers = Record
- AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags: Integer;
- End;
- Var
- Reg: Registers;
- AL: Integer;
- Begin
- Ch:=#0; Extended:=False;
- If KeyPressed Then
- Begin
- Reg.Ax:=$0800; { -Set AH as $8 for Dos Function call }
- Intr($21,Reg); { -Calls Interupt $21 for Dos Fucntion call}
- AL:=(Reg.AX AND $00FF); { -Derive AL from AX }
- Ch:=Chr(AL); { -Set Ch to character to AL }
- If Ch=#0 then
- Begin { Routine to get extended character scan code }
- Reg.Ax:=$0800;
- Intr($21,Reg);
- Ch:=Chr((Reg.AX AND $00FF));
- Extended:=True;
- End;
- End;
- End;
-
-
- Begin
- LowVideo;
- Write('Enter Line:');
- Repeat
- GetChar(Ch,Extended);
- If Ch<>#0 then
- Begin
- If Extended then NormVideo Else LowVideo;
- If Ch=#8 then Write(#8,' ',#8)
- Else Write(Ch);
- End
- Else
- Begin
- Count:=Count+1;
- If Count=5000 then
- Begin
- Count:=0;
- Sound(1000); Delay(100); NoSound;
- End;
- End;
- Until Ch=#13;
- End.
-