.TITLE GTLIN -- GET LINE FROM TI: .IDENT /V1.01/ .NLIST TOC,SYM .ENABL LC ;+ ; Author: C J Doran Date: 2-Nov-81 ; Sira Institute Ltd., ; South Hill, Chislehurst, Kent, BR7 5EH, England. ; ; SUBROUTINE GTLIN(REPLY{,PROMPT}) ; or FUNCTION IGTLIN(REPLY{,PROMPT}) ; ; This subroutine is similar to the RT-11 Syslib GTLIN subroutine, ; except that it does not read from the indirect command file. ; Additional function IGTLIN returns length of string read (if any); ; a negative value indicates a QIO error. ; It reads string REPLY from TI: on the error message LUN, .MOLUN, ; after issuing a prompt PROMPT, if given. If the prompt string ; terminates with a null, it is followed by a CR/LF, which may be ; suppressed by terminating with octal 200 instead. ; ; Doing I/O direct to .MOLUN guarantees that it will go via TI:, ; rather than wherever the TYPE LUN has been assigned. Further, it ; saves having a file control buffer for terminal I/O. The disadvantage ; is that only text can be transferred -- you must ENCODE into a string ; to print numbers, and similarly use DECODE to read them. However, ; unlike ACCEPT and TYPE, GTLIN can be called from a USEREX-defined ; subroutine, as they do not require any files to be open. ; ; Assemble as: ; >MAC GTLIN=GTLIN ; ; Include this module in the user task-build list. Do NOT allow for the ; message output LUN in the ACTFIL, UNITS, or ASG task-builder options, ; as TKB does this automatically. ; ; See also the error message processing facilities described in the ; FORTRAN-IV-PLUS Object Time System Reference Manual (AA-1874B-TC), ; Section 7. Note, however, that GTLIN will work regardless of whether ; or not the error message processor, $ERRLO/$ERRMO, is included in the ; task; i.e. even if F4PNER is used. ;- .PSECT $CODE1,RW,I,LCL,REL,CON W.QIO=20 ; Offset to address of .MOLUN QIO DPB IGTLIN:: GTLIN:: MOV @#$OTSV,%3 ; Address OTS impure data area MOV W.QIO(%3),%2 ; Get address of .MOLUN QIO DPB MOV .MOLUN,Q.IOLU(%2) ; Put in MO LUN number ADD #Q.IOPL,%2 ; Point to parameter list start CMP (%5)+,(%5)+ ; Advance pointer to prompt argument CLR %0 ; Preset return string length CMPB -4(%5),#1 ; How many arguments? BLT EXIT ; Do nothing if none BEQ 10$ ; Just read if only one JSR PC,$MOMSG ; Print prompt 10$: CMP -(%5),#177777 ; Any REPLY argument? BEQ EXIT ; No, return (with 0 in %0 still) MOV #IO.RVB,Q.IOFN-Q.IOPL(%2) ; Set up for a read CMP -(SP),-(SP) ; Need a status block MOV SP,Q.IOSB-Q.IOPL(%2) ; Put address in DPB MOV @%5,(%2)+ ; Load address of REPLY MOV #132.,@%2 ; Up to 132. bytes JSR PC,$MOQIO ; Get line MOV #IO.WVB,Q.IOFN-Q.IOPL(%2) ; Reset DPB, back to write, CLR Q.IOSB-Q.IOPL(%2) ; and no status block MOVB (SP)+,%0 ; Did QIO work? BMI 20$ ; No, return error code MOVB @SP,%0 ; Yes, get bytes read ADD @%5,%0 ; Point to end of string CLRB @%0 ; Terminate with null MOV @SP,%0 ; Return byte count 20$: TST (SP)+ ; Purge stack JSR PC,$MONLN ; Newline to avoid overprint EXIT: RTS PC ; Return to caller .END