DOS Console I/O

Reference Section

_check_key
_flush_keys
_fput_str
_get_chr
_get_chra
_get_chrae
_get_chre
_get_str
_put_beep
_put_chr
_put_newline
_put_str

_check_key


Descrip
Checks STDIN to determine if a keystroke is waiting to be read.

Syntax
#include <dosio.h>
int _check_key(void);

Returns
1 if a keystroke is waiting to be read.

0 if no keystroke is waiting to be read.

Notes
This function determines if a keystroke is waiting to be read at the STDIN device. O is returned if a key is waiting to be read; otherwise, 1 is returned. Redirection, ctrl-break and ctrl-C checking are supported.

This function is typically used prior to calling _get_chr or _get_chre to allow background processing while waiting for a keystroke.

C/C++ Example
	   ...
	   if (_check_key())
	   {
	      _put_str ("\n\rKeystrokes are in the buffer--flushing");
	      _flush_keys ();
	   } else
	      _put_str ("\n\rNo keystrokes are in the buffer");
	   ...

Inline Assembly Example
	#include <inline.h>
	{
	   ...
	   check_key ();	/* is keystroke pending? */
	    jnecheck_key_010/*   n: display "No" message */
	   _put_str ("\n\rKeystrokes are in the buffer--flushing");
	   flush_keys ();
	   jmp short check_key_020

	check_key_010:
	   _put_str ("\n\rNo keystrokes are in the buffer");
	check_key_020:
	   ...
	}

Source file _DIOCHKE.ASM ASM equiv CHECK_KEY
See also
_ccheck_key

_flush_keys


Descrip
Flushes pending input from STDIN.

Syntax
#include <dosio.h>
void _flush_keys(void);

Returns
None

Notes
This function flushes all characters which are waiting to be read from the STDIN device. Redirection, ctrl-break and ctrl-C checking are supported. If redirection is in effect, all redirected input characters are flushed.

C/C++ Example
	   ...
	   if (_check_key ())
	   {
	      _put_str ("\n\rKeystrokes are in the buffer--flushing");
	      _flush_keys ();
	   }
	   else
	      _put_str ("\n\rNo keystrokes are in the buffer");
	   ...

Inline Assembly Example
	#include <inline.h>
	   check_key ();	/* is a keystroke waiting? */
	    jnecheck_key_010/*   n: write "no" message */
	   _put_str ("\n\rKeystrokes are in the buffer--flushing");
	   flush_keys ();
	   jmp short check_key_020

	check_key_010:
	   _put_str ("\n\rNo keystrokes are in the buffer");
	check_key_020:
	...

Source file DIOFLKEY.ASM ASM equiv FLUSH_KEYS
See also
_check_key

_fput_str


Descrip
Puts a string to STDOUT.

Syntax
#include <dosio.h>
void _fput_str(char far *string);

Notes
See _put_str.

Source file _DIOFPST.ASM ASM equiv PUT_STR

_get_chr


Descrip
Gets a character from STDIN.

Syntax
#include <dosio.h>
int _get_chr(void);

Returns
The character code if the keystroke was a normal or ALT-keypad character.

0 if the keystroke was an extended keystroke (the character code is obtained on the next call to _get_chr).

Notes
This function gets a character from the STDIN device. No echoing is performed. If no characters are waiting to be read, this function waits until a key is pressed. Redirection, ctrl-break checking, and ctrl-C checking are supported. 0 is returned if an extended keystroke is retrieved from STDIN. If 0 is returned, the next call to _get_chr returns the character code of the extended keystroke.

This function is similar to C's getch function. It is included to provide similar functionality. Use of _get_chra is preferable.

WARNING! If STDIN is redirected from a file and the last character in the file is a NULL, this function will interpret the NULL as an extended character flag and it will wait indefinitely for the second half of the extended character to become available.

C/C++ Example
	{
	   char chr;
	   chr = _get_chr ();
	   if (chr != 0)
	   {
	      /* handle regular keystroke */
	   } else
	   {
	      chr = _get_chr ();
	      /* handle extended keystroke */
	   }
	}

Inline Assembly Example
	#include <inline.h>
	   get_chr ();	/* AL = chr */
	    jc get_chr_010
	   ... 	 	/* regular keystroke */
	   jmp short get_chr_020

	get_chr_010:
	   ... 	 	/* extended keystroke */
	get_chr_020:
	   ...

Source file _DIOGCHR.ASM ASM equiv GET_CHR
See also
_cget_chr, _get_chr, _check_key, _get_chr, _get_chr, _get_str, _hget_chr, _put_chr

_get_chra


Descrip
Gets a character from STDIN.

Syntax
#include <dosio.h>
int _get_chra(char *chr);

Returns
0 if a normal or ALT-keypad character was retrieved from STDIN.
chr character code

-1 if an extended character was retrieved from STDIN.
chr character code for extended character

Notes
This function gets a character from the STDIN device and copies it into chr. No echoing is performed. If no characters are waiting to be read, this function waits until a key is pressed. Redirection, ctrl-break checking, and ctrl-C checking are supported. -1 is returned if an extended keystroke is retrieved from STDIN; otherwise, 0 is returned.

This function provides an alternative to using two calls to obtain an extended character value. chr always contains the character code regardless of the character type; this allows the programmer to switch on the return value to determine how chr should be processed.

WARNING! If STDIN is redirected from a file and the last character in the file is a NULL, this function will interpret the NULL as an extended character flag and it will wait indefinitely for the second half of the extended character to become available.

C/C++ Example
	{
	   char chr;
	   if (_get_chra (&chr) == 0)
	   {
	      /* handle regular keystroke */
	   } else
	   {
	      /* handle extended keystroke */
	   }
	}

Inline Assembly Example
	#include <inline.h>

	   get_chr ();/* AL = new chr */
	    jc get_chr_010
	   ... 	 /*  handle regular keystroke */
	   jmp short get_chr_020

	get_chr_010:
	   ... 	 /* handle extended keystroke */

	get_chr_020:

Source file _DIOGCHA.ASM ASM equiv GET_CHR
See also
_cget_chr, _get_chr, _get_chr, _get_chr

_get_chrae


Descrip
Gets a character from STDIN and echoes it to STDOUT.

Syntax
#include <dosio.h>
int _get_chrae(char *chr);

Returns
0 if a normal or ALT-keypad character was retrieved from STDIN.
chr character code

-1 if an extended character was retrieved from STDIN.
chr character code for extended character

Notes
This function gets a character from the STDIN device, echoes it to the STDOUT device, and copies it into chr. The character is echoed only if it is a normal or ALT-keypad character in the range 0x20 to 0x7E. All characters which are ALT-keypad characters are returned as normal characters. If no characters are waiting to be read, this function waits until a key is pressed. Redirection, ctrl-break checking, and ctrl-C checking are supported. If an extended keystroke is retrieved from STDIN, -1 is returned. Otherwise 0 is returned.

This function provides an alternative to using two calls to obtain an extended character value. chr always contains the character code regardless of the character type; this allows the programmer to switch on the return value to determine how chr should be processed.

WARNING! If STDIN is redirected from a file and the last character in the file is a NULL, this function will interpret the NULL as an extended character flag and it will wait indefinitely for the second half of the extended character to become available.

C/C++ Example
	{
	   char chr;
	   if (!_get_chrae (&chr))
	   {
	      /* handle regular keystroke */
	   } else
	   {
	      /* handle extended keystroke */
	   }
	}

Inline Assembly Example
	#include <inline.h>
	   ...
	   get_chre ();	/* AL = chr, is chr extended? */
	    jc get_chre_010/*   y: handle extended key */
	   ... 	 	/*   n: handle regular key */
	   jmp short get_chre_020

	get_chre_010:
	   ... 	 	/* handle extended keystroke */
	get_chre_020:
	   ...

Source file _DIOGCAE.ASM ASM equiv GET_CHRE
See also
_cget_chr, _get_chr, _get_chr, _get_chr, _get_chr

_get_chre


Descrip
Gets a character from STDIN and echoes it to STDOUT.

Syntax
#include <dosio.h>
int _get_chre(void);

Returns
Character code if the keystroke was a normal or ALT-keypad character.

0 if the keystroke was an extended keystroke (the character code is obtained on the next call to _get_chre).

Notes
This function gets a character from the STDIN device and echoes it to the STDOUT device. The character is echoed only if it is a normal or ALT-keypad character in the range 0x20 to 0x7E. All characters are returned. ALT-keypad characters are returned as normal characters. 0 is returned if an extended keystroke is retrieved from STDIN. If 0 is returned, the next call to _get_chre returns the value of the extended keystroke.

If no characters are waiting to be read, this function waits until a key is pressed. Redirection, ctrl-break checking, and ctrl-C checking are supported.

This function is similar to C's getche function. It is included to provide similar functionality. Use of _get_chrae is preferable.

WARNING! If STDIN is redirected from a file and the last character in the file is a NULL, this function will interpret the NULL as an extended character flag and it will wait indefinitely for the second half of the extended character to become available.

C/C++ Example
	{
	   char chr;
	   chr = _get_chre ();
	   if (chr)
	   {
	      /* handle regular keystroke */
	   } else
	   {
	      chr = _get_chre ();
	      /* handle extended keystroke */
	   }
	}

Inline Assembly Example
	#include <inline.h>
	...
	get_chre ();/* AL = new chr, is chr extended? */
	 jc get_chre_010/*   y: handle extended keys */
	...    	 /*   n: handle regular keys */
	jmp short get_chre_020

	get_chre_010:
	...    	 /* handle extended keystroke */
	get_chre_020:
	...

Source file _DIOGCHE.ASM ASM equiv GET_CHRE
See also
_cget_chr, _get_chr, _get_chr, _get_chr

_get_str


Descrip
Gets a string from the STDIN device.

Syntax
#include <dosio.h>
char *_get_str(char *buffer, char num);

Returns
A pointer to buffer.
buffer ASCIIZ string retrieved from STDIN

Notes
This function gets up to num characters from the STDIN device and places them in buffer. Each character is echoed as it is read if it is a normal or ALT-keypad character in the range 0x20 to 0x7E. Non-echoed characters are not placed in buffer. If an attempt is made to enter more than num characters into the buffer, the BEL character is echoed to STDOUT and the character is ignored. If the backspace key is pressed, the last character in buffer is removed and the last character echoed to STDOUT is overwritten with a space character. If the Enter key is pressed, a NULL character is placed after the last character written into buffer, a CR and a LF are echoed to STDOUT, and the function returns. Redirection, ctrl-break checking, and ctrl-C checking are supported.

WARNING! buffer must be at least num+3 bytes in size. The contents of the two bytes in buffer just beyond the end of the returned ASCIIZ string are undefined.

WARNING! Even if _cbrk_disable has been used to disable ctrl-break checking, a ctrl-C will still cause a ^C and a CR/LF to be written to STDOUT. However, calling _cbrk_disable will prevent the ctrl-break handler from receiving control.

C/C++ Example
	{
	   char str[10];
	   ...
	   _get_str (str, 9);/* process the string */
	   ...
	}

Inline Assembly Example
	#include <inline.h>
	{
	   char str[10];
	   ...
	   mov cl,9	/* CL = max # chars to read */
	   lea si,str	/* SI -> str buffer */
	   get_str ();	/* get a max of CL chars */
	   put_str ();	/* write them to STDOUT */
	   ... 	 	
	}

Source file _DIOGSTR.ASM ASM equiv GET_STR
See also
_cget_s, _get_chr, _get_script, _vget_script, _hget_str

_put_beep


Descrip
Puts a BEL character to STDOUT.

Syntax
#include <dosio.h>
void _put_beep(void);

Returns
None

Notes
This function sends a BEL character to the STDOUT device. The BEL character may be redirected.

C/C++ Example
	   _put_beep ();

Inline Assembly Example
	#include <inline.h>
	   put_beep ();

Source file DIOPBEEP.ASM ASM equiv PUT_BEEP
See also
_cput_beep, _put_chr

_put_chr


Descrip
Puts a character to STDOUT.

Syntax
#include <dosio.h>
void _put_chr(int chr);

Returns
None

Notes
This function writes chr to the STDOUT device. Redirection is supported. If redirection is not being performed, then the character is displayed on the screen at the current cursor position.

The following characters receive special interpretation by the STDOUT device: BEL, BS, TAB, LF, and CR. All other characters are written to STDOUT without modification.

C/C++ Example
	   _put_chr ('c');/* write 'c' to STDOUT */

Inline Assembly Example
	#include <inline.h>
	   mov al,'a'/* AL = char to write */
	   put_chr ();/* write it to STDOUT */

Source file _DIOPCHR.ASM ASM equiv PUT_CHR
See also
_get_chr, _cput_chr, _hput_chr, _put_str

_put_newline


Descrip
Puts a carriage return and linefeed to STDOUT.

Syntax
#include <dosio.h>
void _put_newline(void);

Returns
None

Notes
This function echoes a CR and a LF to the STDOUT device. Redirection is supported. If redirection is not being performed, then this function returns the cursor to the left-most column of the screen and moves it down one line.

C/C++ Example
	   _put_newline();

Inline Assembly Example
	#include <inline.h>
	   put_newline();

Source file DIOPNLIN.ASM ASM equiv PUT_NEWLINE
See also
_cput_newline

_put_str


Descrip
Puts a string to STDOUT.

Syntax
#include <dosio.h>
void _put_str(char *string);

Returns
None

Notes
This function writes an ASCIIZ string to STDOUT. Each character of string is copied to STDOUT except the terminating NULL character. Redirection is supported. If redirection is not being performed, then the string is displayed starting at the current cursor position.

The following characters receive special interpretation by the STDOUT device: BEL, BS, TAB, LF, and CR. All other characters are written to STDOUT without modification.

C/C++ Example
	   char *str = "Hello, world";
	   _put_str(str)

Inline Assembly Example
	#include <inline.h>
	{
	   char str[10];
	   ...
	   mov cl,9	/* CL = max # of chars to read */
	   lea si,str	/* DS:SI -> str buffer */
	   get_str ();	/* get a max of CL chars */
	   put_str ();	/* write them to STDOUT */
	   ... 	 	/* process the string */
	}

Source file _DIOPSTR.ASM ASM equiv PUT_STR
See also
_cput_str, _fput_str, _hput_str, _put_chr, _put_script, _vput_script