.TITLE QIOExample ; Purpose: Illustrates simple Queue I/O input and output by printing ; a prompt and then inputting character strings and echoing ; until STOP is entered. ; Notes: ; 1. Only works on interactive runs connected to a terminal. ; 2. Adapted from VAX/VMS System Services Reference Manual. ; .... Setup descriptions of the terminal for Queue I/O .... TTName: .ASCID "Sys$Input" ; Descriptor for terminal name TTChan: .BLKW 1 ; Reserve room for channel number TTIOSB: .BLKW 1 ; I/O status block: status, TTIOLen: .BLKW 1 ; length, .BLKL 1 ; other info ; .... Setup buffers for I/O .... LenBuf = 81 IOLen: .BLKL 1 ; Length of string in IOBuf IOBuf: .BLKB LenBuf ; I/O buffer InstBuf: .ASCII "Enter a string:" ; Instruction buffer LenInst = . - InstBuf ; Length of instruction buffer ; = current loc - InstBuf loc ; .... Input macro .... ; Uses $QIOW_S to input from a terminal and checks for errors .MACRO TerminalInput - ; Input from terminal ... Buffer, - ; input buffer Length ; length of input buffer $QIOW_S Chan = TTChan, - ; Channel for I/O Func = #IO$_ReadVBlk,-; function: Read a virtual block IOSB = TTIOSB, - ; put status in TTIOSB P1 = Buffer, - ; put input in Buffer P2 = Length ; maximum length of buffer BSBW CheckQueueAndCompletionStatus .ENDM TerminalInput ; .... Output macro .... ; Uses $QIOW_S to output to a terminal and check for errors .MACRO TerminalOutput - ; Output to a terminal ... Buffer, - ; output buffer Length ; length of input buffer $QIOW_S Chan = TTChan, - ; Channel for I/O Func = #IO$_WriteVBlk, - - ; function: Write a virtual block IOSB = TTIOSB, - ; put status in TTIOSB P1 = Buffer, - ; output buffer P2 = Length, - ; length of buffer P4 = #^X8D010000 ; carriage control BSBW CheckQueueAndCompletionStatus .ENDM TerminalOutput ; .... The program .... .Entry QIOExample, 0 ; .... Assign channel to terminal .... Start: $ASSIGN_S - ; Assign channel DevNam=TTName, - ; logical name of device Chan=TTChan ; channel number returned BSBW CheckEr ; .... Issue the instruction (prompt) to the user .... TerminalOutput - ; Print instruction Buffer=InstBuf,- ; address of instruction Length=#LenInst ; length of instruction ; .... Input and echo a string and repeat until 'stop' .... Repeat: TerminalInput - ; Input a string Buffer=IOBuf, - ; put in IOBUF Length=#LenBuf ; maximum length=#LenBuf MOVZWL TTIOLen, IOLen ; Get length from TTIOSB TerminalOutput - ; Output a string Buffer=IOBuf, - ; location of string Length=IOLen ; length of string CMPL #^A'STOP', IOBuf ; 'Stop' run? BEQL Done CMPL #^A'stop', IOBuf BEQL Done BRW Repeat ; Otherwise repeat ; .... Terminate run .... Done: $DASSGN_S - ; First, deassign channel Chan=TTChan BSBW CheckEr $EXIT_S ; .... Subroutines to check for errors .... ; (errors are signaled by an even number) CheckQueueAndCompletionStatus: BLBC R0, ErStop ; Branch if queue error MOVZWL TTIOSB, R0 ; Move completion status to R0 CheckEr: BLBC R0, ErStop ; Branch if error RSB ; Otherwise return ErStop: $EXIT_S R0 ; Finished .END QIOExample