First, I apologize if this is the wrong arena to pose this question.
If it is, please direct me to the correct one.
Is there a system/rtl function which can be called from C which will
allow me to read "n" characters from the terminal (Possibly QIO
functions?) If so, how do I call them using C.
What I want is an auto-advance feature after input has reached a
specified length.
Thanks
The $QIO(W) system service has several options for determining when
an I/O is complete. If you request "n" characters, do not specify a
timeout and specify a null terminator mask, the I/O will complete only
when exactly "n" characters have been entered. You may combine this
with terminators so that the I/O will complete before "n" characters
if certain characters are detected. You may also choose to enable
or disable command line editting, echo, input verification etc...
A short example is appended.
Example-C $QIO Read From Terminal Using A Short Form Terminator Mask
COPYRIGHT (c) 1988, 1993 by Digital Equipment Corporation.
ALL RIGHTS RESERVED. No distribution except as provided under contract.
Copyright (c) Digital Equipment Corporation 1993. All rights reserved
PRODUCT: VAX C
OP/SYS: OpenVMS VAX
SOURCE: Digital Customer Support Center
OVERVIEW:
This program will demonstrate how to combine function codes and modifiers and
use the short form of the terminator mask such that control-characters in the
range of 0 - 31 (decimal) can be used to terminate the read operation.
*** CAUTION ***
This sample program has been tested using VAX C V3.2 on OpenVMS VAX V6.0.
However, we cannot guarantee its effectiveness because of the possibility of
error in transmitting or implementing it. It is meant to be used as a template
for writing your own program, and it may require modification for use on your
system.
PROGRAM NOTES:
The size of the input buffer and the length of the input buffer specified
in the P2 argument of the QIO can be modified to accomodate single
character to multiple character input lengths. The read will terminate if
the length of the input exceeds the length of the input buffer.
If the line-editing characteristic of the terminal is on, only ctrl-z,
CR, or an escape sequence will terminate. Refer to section 8.2.1.2 in
the IO user's guide.
Certain function code modifiers may be needed depending upon which
control-characters are to be specified as terminators.
In this example, ctrl-e and ctrl-b will be setup as terminators.
PROGRAM:
#include stdio
#include iodef
#include descrip
#include ssdef
main()
{
typedef struct /* template for QIO read iosb. refer to section 8.5 in */
{ /* the IO users guide (part 1) for detailed info. */
short cond_value;
short offset;
short term;
short term_size;
} status_block;
short func_code=0;
short tt_chan=0;
int term_mask[2];
register status;
char inchar[80];
status_block iosb;
$DESCRIPTOR(terminal,"TT:");
/* set up the short-form terminator mask to set ctrl-e (decimal 5) and */
/* ctrl-b (decimal 2) as terminators. With the short-form of the terminator */
/* mask, the control-character is a terminator if the bit corresponding to */
/* its decimal value is set. */
term_mask[0] = 0;
term_mask[1] = ((1 << 2) | (1 << 5));
/* Assign an I/O channel to device. */
if (((status=SYS$ASSIGN(&terminal,&tt_chan,0,0)) &1) != 1)
LIB$STOP(status);
printf("Enter some data, terminate with ctrl-e or ctrl-b: ");
/* Combine function code and modifier with a bitwise OR */
func_code=IO$_READVBLK | IO$M_NOFILTR;
status = SYS$QIOW(0,tt_chan,func_code,&iosb,0,0,&inchar,80,0,&term_mask,0,0);
if ((status & 1) != 1)
LIB$STOP(status);
/* Check the I/O status block */
if ((iosb.cond_value & 1) != 1)
LIB$STOP(iosb.cond_value);
inchar[iosb.offset] = '\0';
printf("\n\nData entered was: %s",inchar);
if (((status = SYS$DASSGN(tt_chan)) & 1) != 1)
LIB$STOP(status);
}
REFERENCE(S):
OpenVMS I/O User's Reference Manual, May 1993, (AA-DPV6SA-TK).
OpenVMS System Services Reference Manual:A-GETMSG, May 1993, (AA-PV6FA-TK).
OpenVMS System Services Reference Manual:GETQUI-Z, May 1993, (AA-PV6GA-TK).