Procedure UNSLCT(lun: integer; efn:Event_Flag; VAR stat: integer); EXTERNAL; {*USER* This is the unsolicited input ast control routine package. Facility is provided to use an event flag to signal unsolicted input. Calling this procedure will activate unsolicted input detection using the unsolicted input AST coupled with a local or global event flag. The lun specified in LUN will be attached with unsolicted input detection activated. When unsolicted input is detected, the program will enter into an enclosed AST routine that will set the event flag specified in EFN. The AST will then exit normally, and the caller can decide what to do. This provides the capability to wait for input (stop/wait on event flag) without committing ourselves to a QIO, and the capability to detect "input in progress" while active elsewhere in the program. STATUS will return a success code (+1) if the port attaches okay, a negative number error code if it does not. To cancel unsolicted input notification, the lun need only be detached using QIOW IO_DET, or call UNSLCT for the lun and specify a zero event flag (f0) for the event flag EFN. As you might expect, this module must be linked into the root of the program since it contains AST code that may be executed anywhere in the program. The lun number specified in LUN can vary from 1 to 30. UNSLCT can be called multiple times to map multiple luns to multiple flags. You can associate each lun with a unique flag, letting you determine which lun tripped the AST, and thus which lun to service. Or you can associate each lun with a single flag, simplifying your wait processing. If you use multiple luns and event flags, you can use the flag to indicate IO in progress on the associated lun. This will not affect the other flags, so that you must check each flag as needed to determine if IO is in progress on other luns. If you call UNSLCT for the same lun twice, the last call will determine the event flag that is used EFN. IMPORTANT: The unsolicited input ast is armed for a lun after calling procedure UNSLCT. The ast remains armed for that lun until an unsolicted character in input on that lun and the ast jumped to. Thereafter, the ast is not armed FOR THAT LUN, and subsequent characters will NOT activate the ast (set the flag). After a QIO (READLN) has been successfully done for the specific lun, the unsolicited character ast will be rearmed and any SUBSEQUENT unsolicited input will activate the ast (set the flag). This means that there is a time between jumping to the ast (setting the flag) and completing the QIO when more characters can be typed in without activating the ast and setting the flag. Thus, to insure airtight input, you should do your QIO (READLN) and CLEF (clear the flag) (the order is not important), and THEN examine the typeahead count with PASUTL routine TYPBUF (or QIOW SF_GMC). If the count is zero (no chars in typeahead), you need do nothing as you already got all the input in your QIO call. If the count is non-zero (characters in typeahead), you should continue reading from the lun (using QIO/READLN), or you should SETF (set the flag) to simulate the action of the ast so that you will be signalled to read the rest of those characters on your next cycle. This routine uses local EFN 24, which is normally reserved for use by P3UTIL routines. }