;*************************** AMUS Program Label ******************************
; Filename: CMDLIN.M68                                      Date: 12/01/89
; Category: SBR          Hash Code: 152-134-755-531      Version: 1.0
; Initials:              Name: Try your name
; Company: Pick one in the US of A.                Telephone #:
; Related Files: XCALL.M68
; Min. Op. Sys.: AMOSL 1.1                     Expertise Level: BEG
; Special:
; Description:  Returns last input line (command line).
;
;
;*****************************************************************************
;*; Updated on 01-Dec-89 at 1:32 PM by Place Name; edit time: 0:05:24
;CMDLIN.SBR
;
;Call:  XCALL CMDLIN, parm$
;
;Where: parm$ = string variable to receive the last input line (command
;               line) and a null byte. The command line is copied until
;               end of line (NULL) or when string is filled.
;
       VMAJOR=1
       VMINOR=0

       OBJNAM  .SBR

       SEARCH  SYS
       SEARCH  SYSSYM
       SEARCH  TRM

;       The following file, XCALL.M68, is located in P,PN [100,52].
;       Copy this file from the Network and place it in DSK0:[7,7].

       COPY XCALL.M68                          ;Saves you from typing it in.
       PHDR    -1,PV$RSM,PH$REE!PH$REU

ENTRY:  CMPW    XC.ARG(A3),#1           ; 1 argument specified?
       BLT     ARGERR                  ;  no
       CMPW    XC.TY1(A3),#XC$STR      ; string argument specified?
       BNE     TYPERR                  ;  no
       MOV     XC.SZ1(A3),D0           ; string size valid?
       BEQ     SIZERR                  ;  no

GETNAM: JOBIDX                          ; index Job Control Block
       MOV     JOBTRM(A6),D6           ; index Terminal Control Block
       BEQ     10$                     ;  no terminal attached to job
       MOV     D6,A1                   ; get terminal address
10$:    MOV     T.ILB(A1),A2            ; point to Last Command Line
       MOV     XC.AD1(A3),A0           ; point A2 to parm$
CPYLNE: LIN                             ; End of line found?
       BEQ     20$                     ; yes, exit loop
       MOVB    (A2)+,(A0)+             ; copy char to parm$ & bump ptr
       BEQ     20$                     ; exit loop, if null found
       SOB     D0,CPYLNE               ; minus 1 from length, & continue
20$:    CLRB    @A0                     ; place end of string w/NUL
       RTN                             ; return

ARGERR: TYPESP  ?Argument count
       BR      ERROR
TYPERR: TYPESP  ?Argument type
       BR      ERROR
SIZERR: TYPESP  ?Argument size
ERROR:  TYPECR  error in CMDLIN.SBR
       RTN

       END