OBJNAM PUTBUF.SBR ; Created 14-Sep-84, last modified 23-Jan-86 ; Forced a list of parameters as input to the user's terminal to allow ; line input editing using RELIEF, LINEED, or EDITLI ; by Irv Bromberg, Medic/OS Consultants, Toronto, Canada RADIX 10 VEDIT=12 VMINOR=3 VMAJOR=2 NoHome=0; <-- change to NoHome=1 to leave cursor at END of displayed line ; %Note NoHome not compatible for RELIEF if KBD patch ON (double display) VSUB=NoHome ; "A" subscript in version number flags NoHome version IF EQ,1 Calling syntax: XCALL PUTBUF,expression {,expression {,expression...}} where each expression in the unlimited list can be an ASCII string or a floating numeric expression (pass binary parameters by value in braces for automatic conversion to floating). PUTBUF converts the parameters in the list of expressions into ASCII format and forces them into the user's input buffer so that the system line editor can be used to edit their concatenated value. Any data to be displayed in excess of the user's terminal's type-ahead input buffer size will be truncated. PUTBUF leaves the cursor at the first character it displayed unless the NoHome flag was set at assembly time. The NoHome flag MUST be set if your system does not have ANY input line editor, else the displayed data will immediately disappear (result of forced ^U). SCALE is supported (scaled floating values) for passed floating expressions. Assembled under AMOS/L 1.3 the normal version 2.3(12) size is 184 bytes with hash code 325-532-623-567 and the NoHome version 2.3A(12) size is 164 bytes with hash code 355-732-537-717. Edit history: 2.1(10) 4-Dec-85 released to AMUS for publication in AMUS.LOG 2.2(11) 11-Dec-85 added support for SCALE (scaled floating values) use user stack for floating workspace 18-Dec-85 made SCALE support conditional assembly option. 30-Dec-85 restored SCALE support as required assembly. 2.3(12) 23-Jan-86 SLEEP #500 in WaitOIP to waste less time NoHome version causes double display with RELIEF when KBD patch is ON, no problem with Normal version. ENDC SEARCH SYS SEARCH SYSSYM SEARCH TRM Impure =A0 String =A1 Float =A1 Buffer =A2 ASCBUF =A2 ArgBas =A3 Worksp =A4 TCB =A5 JCB =A6 Pcount =D0 Char =D1 End =D2 Count =D3 CR=13 CTRL=-64. SCALE=128 ; =offset to SCALE value in BASIC impure area PHDR -1,0,PH$REE!PH$REU ; re-entrant & re-useable CLR Char ; pre-clear for byte move MOV JOBCUR,JCB ; fool line editor system to think ORW #J.TIW,JOBSTS(JCB) ; we are waiting for input MOV JOBTRM(JCB),TCB ; get user's TCB pointer for TRMICP MOV T.IBS(TCB),Count ; get input buffer size SUB #5,Count ; allow for CR LF NULL, DBF pre-decr MOVW @ArgBas,Pcount ; get number of parameters passed BR CntDwn ; enter at end of DBF loop NxtPar: MOV 4(ArgBas),String ; get address of next parameter CMPB 2(ArgBas),#4 ; was numeric expression passed? BEQ GetNum ; yes, get it MOV String,End ; calculate end address of string ADD 8(ArgBas),End NxtChr: CMP String,End ; reached end of string? BEQ Add10 MOVB (String)+,Char ; get next char, is it NULL? BEQ Add10 TRMICP ; force it to self DBF Count,NxtChr ; force all that will fit then BR Add10 ; go move cursor to home editing pos'n GetNum: SUB #26,SP ; get some workspace for ASCII cvt MOV SP,Worksp ; point to the workspace MOVB (Float)+,(Worksp)+ MOVB (Float)+,(Worksp)+ MOVB (Float)+,(Worksp)+ MOVB (Float)+,(Worksp)+ MOVB (Float)+,(Worksp)+ MOVB (Float)+,(Worksp)+ MOV Worksp,ASCBUF ; ASCII conversion after float value MOV SP,Worksp ; reset pointer MOV Scale(Impure),D7 ; SCALE factor in use? BEQ 10$ NEG D7 ; yes, adjust the scaled value FPWR @Worksp,D7 10$: FCVT @Worksp,1,,11,0 CLRB @ASCBUF ; terminate the ASCII converted value LEA ASCBUF,6(SP) ; point to start of string image NxtDig: MOVB (ASCBUF)+,Char ; get next digit BEQ 10$ ; terminate on NULL TRMICP ; force it to self DBF Count,NxtDig ; go back for more until buffer full 10$: ADD #26,SP ; return the workspace ; fall through to decrement the parameter count Add10: ADD #10,ArgBas ; point to next element in arg list CntDwn: TST Count ; buffer full? if not then go back DBMI Pcount,NxtPar ; for more parameters if any left Home: ; Home the cursor to the first character we displayed. This is a ; matter of preference -- you may wish to assemble two versions of ; this subroutine, with and without the cursor home instructions. IF EQ,NoHome ASMMSG "Cursor will be left at first displayed character" MOVB #CTRL+'U,Char ; home cursor to start of line WaitOIP:TSTB T.STS(TCB) ; Wait for OIP to finish else BPL 10$ ; LINEED will ignore the ^U SLEEP #500 BR WaitOIP 10$: TRMICP IFF ASMMSG "Cursor will be left at end of displayed line" ENDC MOV JOBCUR,JCB ; get it again (temporary register) ANDW #^C,JOBSTS(JCB) ; undo fake input wait state RTN END .