HPlogo Asynchronous Serial Communications Programmer's Reference Manual: HP 3000 MPE/iX Computer Systems > Chapter 6 Typeahead Mode

Working in Typeahead Mode

» 

Technical documentation

Complete book in PDF
» Feedback

 » Table of Contents

 » Glossary

 » Index

By using the device controls described in this chapter, you can specify whether or not typeahead mode is enabled when your program executes. By allowing typeahead mode you can make it possible for the user of the application to enter data that the user knows will be required before the application actually requests the data.

Suppose, for example, that your program issues a series of questions designed to allow an interactive user with the proper access codes to gain entry to a database program. Without typeahead mode active, the program writes each question on the user's terminal screen and waits for a reply. Each reply may require some additional processing before the next question is written to the screen. In some cases, the delay between questions may be quite noticeable.

If typeahead mode is on, however, a user who is familiar with the series of questions can type replies to all of the questions at once, without regard to processing delays. As long as the replies are entered in the required sequence for the application and are separated from each other by an end-of-record character (such as carriage return), they will be accepted as valid replies.

After all of the replies have been entered, the user will still have to wait for the application to process the replies before being granted access to the database. But now all of the waiting is at the end of the question sequence, and the user is free to perform some other task instead of having to wait for the next question.

Enabling Typeahead Mode

As of version A.30.00 of MPE/iX, a terminal user can enable typeahead mode at the Command Interpreter level for any supported terminal. The command :SETVAR HPTYPEAHEAD TRUE enables typeahead, while the command :SETVAR HPTYPEAHEAD FALSE disables typeahead. (These commands replace the command file used to set typeahead mode in earlier MPE/iX versions supporting typeahead.)

In order for typeahead to be used in an application, however, the application itself must programmatically enable and manage typeahead through the FDEVICECONTROL functions explained in this chapter.

WARNING! No attempt should be made to use typeahead mode at a terminal that is running an application which has not been specifically coded for typeahead processing.

How Typeahead Mode Works

When data is entered from a terminal with typeahead mode active, the data is staged in a special typeahead buffer before being sent through to the process requesting the data. Any read posted against a terminal with typeahead mode active will first access the typeahead buffer, rather than accepting data directly from the device.

The typeahead buffer is limited to 224 bytes; anything in excess of this limit will cause an XOFF to be sent. You should be sure that XON/XOFF transmission pacing is enabled for the terminal if typeahead mode is used. You should avoid using typeahead mode if you anticipate that reads will exceed 224 bytes, to avoid overflowing the typeahead buffer.

If typeahead is on but the terminal user has not typed ahead, the system will act in essentially the same way that it would if typeahead were not enabled. A DC1 read trigger will be sent to the terminal any time the system is ready to receive data, and there is no data in the typeahead buffer. If, however, the user has typed ahead, and there is data in the buffer, the system will simply accept the typed ahead data and will not send a DC1 read trigger to the terminal.

Typeahead Mode and Echo

When typeahead is in use the terminal user will, in most cases, see input echoed to the terminal twice. The first echo is a "convenience echo", which appears when the data is being typed. This echo allows the user to see the characters that are typed, and to make corrections, if necessary, before entering the end-of-record character.

The second echo appears at the time the data in the typeahead buffer is actually accepted by the system. This echo lets the user know that the read is being processed.

A second type of typeahead mode exists—single echo typeahead mode. With this mode, the device driver withholds the echoing of typeahead data until a read is posted for the data.

There are, however, certain cases in which the first echo will not be seen at the terminal. For example, if the terminal user types ahead while the system is displaying data, such as the output to a :LISTF command, the convenience echo will not appear.

Also, a user whose terminal is in typeahead mode but who is not typing ahead will see the input echoed only once.

Typeahead Mode and Subsystem Break

When typeahead mode is active, the subsystem break character has additional functionality when typeahead is used, regardless of whether or not subsystem break is enabled. Receipt of the subsystem break character causes all data in the typeahead buffer to be discarded. This provides the user with a final chance to erase a previously typed command. But this feature should be used with caution; subsystem break does, after all, have its own function. Users who depend on this method to flush the typeahead buffer may find themselves processing undesired subsystem breaks if subsystem break is enabled.

Feedback to webmaster