[an error occurred while processing this directive]

HP OpenVMS Systems

Ask the Wizard
» 

HP OpenVMS Systems

OpenVMS information

» What's new on our site
» Upcoming events
» Configuration and buying assistance
» Send us your comments

HP OpenVMS systems

» OpenVMS software
» Supported Servers
» OpenVMS virtualization
» OpenVMS solutions and partners
» OpenVMS success stories
» OpenVMS service and support
» OpenVMS resources and information
» OpenVMS documentation
» Education and training

Quick Links

» Non-javascript page
» Ask the Wizard
» OpenVMS FAQ

Test Drive OpenVMS

» OpenVMS I64 test drive
» Java test drive

Other information resources available to you include:

» OpenVMS freeware
» ECO kits, software and hardware support, prior version support
» Alpha SRM, ARC, and AlphaBIOS firmware updates
» ENCOMPASS - HP user group
» OpenVMS software downloads, OpenVMS freeware CD-ROM
» OpenVMS firmware locations
» DECconnect passive adaptor charts
» Cables reference guide
» MicroVAX console commands
» OpenVMS student research

Select a topic below to see Questions Frequently Asked by partners

» Using the online documentation library(installing BNU from the asap SDK)
» Global sections(how to create and use.)
» xx$CREATE_BUFOBJ system service(usage)
» Ethernet address(methods of determination)
» Shareable images(cookbook approach to creating one)
» Sharing data/code at absolute addresses(a guide with examples)
» Determining the Alpha microprocessor
» Using GETSYI to get hardware status

Evolving business value

» Business Systems Evolution
» AlphaServer systems transition planning
» Alpha RetainTrust program

Related links

» HP Integrity servers
» HP Alpha systems
» HP storage
» HP software
» HP products and services
» HP solutions
» HP support
disaster proof
HP Integrity server animation
HP Integrity server animation
Content starts here

Ask the Wizard Questions

C Language: Terminal $QIO from C

The Question is:


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 Answer is:


      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).