;       SETX.M68
;       VER 1.0         8611.20
;       
;       ALLOW USER TO SET/RESET THE USER NAME AND THE COMMAND LINE
;               IN THE JOB CONTROL BLOCK
;
;       PROPRIETARY PROGRAM MATERIAL
;
;       THIS MATERIAL IS THE PROPERTY OF JEFF STUYVESANT,
;       12307 PACIFIC AVE, APT 2,MAR VISTA, CALIF. ,90066
;       PERMISSION TO COPY AND USE IS GRANTED FOR 
;       NON-PROFIT USES ONLY.
;
;       Copyright (c) 1986 JEFF STUYVESANT


        SEARCH  SYS
        SEARCH  SYSSYM
        SEARCH  TRM
        

        RADIX 8.
        
VMAJOR  =       1.
VMINOR  =       0.
VSUB    =       0.
VEDIT   =       0.
VWHO    =       0.



        PHDR    -1,0,PH$REE!PH$REU

START:  ; A2 POINTS TO INPUT LINE

        BYP
        LIN
        BEQ     SEL%ERR
        MOVW    #0,D0
        LEA     A1,SEL%LST                              ; POINT TO SELECTION LIST
10$:    CMMB    @A2,4(A1)                               ; CMP THE TWO
        BEQ     200$                                    ; IF MATCH CKECK REMAINDER
        BLO     SEL%ERR                                 ; IF LOW GONE TO FAR ERROR
        ADD     @A1,A1                                  ; POINT TO NEXT
        BR      10$

100$:   ADD     @A1,A1
        MOV     A0,A2
        BR      10$

200$:   ; A2 POINTS TO INPUT: A1 POINTS TO PROMPT LIST SELECTION

        MOVW    #-1,D0                                  ; COUNTER
        MOV     A2,A0                                   ; SAVE A2
        
220$:   INC     D0                                      ; POINT TO NEXT
        TRM                                             ; END OF INPUT ?
        BEQ     FOUND                                   ; IF END WE'VE FOUND IT
        CMPB    4(A1)[~D0],#0                           ; END OF PROMPT?
        BEQ     100$                                    ; BR IF YES - NO GOOD LOOK SOME MORE
        CMMB    (A2)+,4(A1)[~D0]                        ; CMP FOR MATCH
        BNE     100$
        BR      220$

FOUND:  ; A1 POINTS TO PROMPT, A2 POINTS TO AFTER INPUTED PROMPT
        JOBIDX  A5
        LEA     A0,10(A1)
        ADD     @A0,A0
        JMP     @A0

SEL%ERR:
        CRLF
        TYPECR  <USAGE: SETX function,{new parameter}>
        CRLF
        TYPECR  <Functions:>
        TYPECR  <       USN  Display or set User name>
        TYPECR  <            (maximum of 19 characters)>
        CRLF
        TYPECR  <       CMD  Display of set Command line>
        TYPECR  <            (maximum of 29 characters)>
        EXIT

SEL%LST:
        LWORD   L%2-.           ; 0
        ASCIZ   \CMD\           ; 4
        LWORD   CMD-.           ; 10
L%2:    LWORD   L%3-.           ; 0
        ASCIZ   \USN\           ; 4
        LWORD   USN-.           ; 10
L%3:    LWORD   0
        BYTE    255.
        BYTE    255.
        EVEN

;
;
; INPUT/EDIT USER NAME
;
USN:    
        BYP                             ; BYPASS ANY BLANKS
        LEA     A0,JOBUSN(A5)           ; POINT TO JOB USER NAME
        TRM                             ; POINT TO TERMINATING CHAR
        BNE     50$                     ; IF NOT TRM THEN STORE

        CMPB    @A0,#0                  ; ANY USER NAME STORED ?
        BNE     10$                     ; IF NE THAN CURRENT STORED

        TYPECR  %No current USER NAME stored
        EXIT
;
; PRINTS OUT USER NAME
10$:
        ; A0 POINTS TO JOBUSN IN MEMORY
        ; A2 POINTS TO INPUT LINE

        TYPE    Current USER NAME: 
        MOVW    #19.,D1
        BR      T.OUT

;
; STORES USER NAME
50$:
        CMPB    @A2,#'*                 ; * IDENT DELETE
        BEQ     200$                    ; TO RTN TO DELETE

        ; A0 POINTS TO JOBUSN IN MEMORY
        ; A2 POINTS TO INPUT LINE

        MOVW    #19.,D1
        BR      STORE
;
; DELETES THE USER NAME
200$:
        ; A0 POINTS TO JOBUSN IN MEMORY
        ; A2 POINTS TO INPUT LINE

        MOVW    #19.,D1

;
; DELETE STORED LINE
DEL:
        MOVW    D1,D0

220$:   MOVB    #0,(A0)+
        DBEQ    D0,220$
        EXIT
;
;
STORE:  ; A0 POINTS TO SELECTED LINE IN MEMORY
        ; A2 POINTS TO INPUT LINE
        ; D1 CONTAINS THE COUNT

        MOVW    D1,D0

80$:    MOVB    (A2)+,(A0)+
        DBEQ    D0,80$
        EXIT
;
;
T.OUT:  ; A0 POINTS TO SELECTED LINE IN MEMORY
        ; A2 POINTS TO INPUT LINE
        ; D1 CONTAINS THE COUNT

        MOVW    D1,D0
        BR      30$

20$:
        TOUT

30$:    MOVB    (A0)+,D1
        DBEQ    D0,20$
;       CRLF
        EXIT

;
;
; INPUT/EDIT CMD LINE
;
CMD:
        BYP                             ; BYPASS ANY BLANKS
        LEA     A0,JOBCMD(A5)           ; POINT TO JOB USER NAME
        TRM                             ; POINT TO TERMINATING CHAR
        BNE     50$                     ; IF NOT TRM THEN STORE

        CMPB    @A0,#0                  ; ANY USER NAME STORED ?
        BNE     10$                     ; IF NE THAN CURRENT STORED

        TYPECR  %No current CMD LINE stored
        EXIT
;
; PRINTS OUT CMD LINE
10$:
        ; A0 POINTS TO JOBCMD IN MEMORY
        ; A2 POINTS TO INPUT LINE

        TYPE    Current CMD LINE: 
        MOVW    #29.,D1
        BR      T.OUT

;
; STORES THE CMD LINE
50$:
        CMPB    @A2,#'*                 ; * IDENT DELETE
        BEQ     200$                    ; TO RTN TO DELETE

        ; A0 POINTS TO JOBCMD IN MEMORY
        ; A2 POINTS TO INPUT LINE

        MOVW    #29.,D1
        BR      STORE
;
; DELETES THE CMD LINE
200$:
        ; A0 POINTS TO JOBCMD IN MEMORY
        ; A2 POINTS TO INPUT LINE

        MOVW    #29.,D1
        JMP     DEL
        END