The information in this article applies to:
SUMMARYThis article provides information and sample code on how to check for the presence of keyboard input and get the keybord input with (or without) echoing the keys to the screen. MORE INFORMATIONPage 273 of the Microsoft FORTRAN version 5.1 "Reference" manual explains how to use the INTDOSQQ and INTDOSXQQ subroutines to invoke MS-DOS Interrupt 21h system calls. Two of these Int 21h functions, functions 7 and 8, get input from the keyboard without echoing that input to the display. The difference between these two functions is that function 7 ignores CTRL+C and CTRL+BREAK characters while function 8 handles these characters by breaking out of the program. The function B (hex) checks to see if a key was pressed. It will return true if a key is waiting to be read, and false if it is called after all of the keys have been read. What the Sample Code DoesThe sample code function GETCH uses MS-DOS Int 21h, function 8 to get a character from Standard Input without echoing it to the screen.The sample code subroutine PUTCHAR uses Int 21h function 2 to write a single character to the screen. The sample code PASSWORD uses GETCH to allow input of a password without echoing the keystrokes to the display. PUTCHAR is used to display an asterisk for each keystroke entered. The sample code function KBHIT uses Int 21h function B(hex) to check if a key was pressed. It returns 0 if no key is available and returns non-zero if a key was pressed. Use GETCH to get the key(s). NOTE: If several of the routines are put into the same file, then the statement: include 'flib.fi'should only be included once at the beginning of that file. (FLIB.FD needs to be included in each subroutine, but FLIB.FI does not.) Sample Code: GETCH
Sample Code: PUTCHAR
Sample Code: PASSWORDC Compile options needed: none
Sample Code: KBHIT
REFERENCESFor detailed information about the various Int 21h functions, consult any MS-DOS programmer's reference manual. Additional query words: kbinf 5.10 getc getchar console putc
Keywords : |
Last Reviewed: November 2, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |