;************************************
;*      CLRPRG.M68
;*
;*      Clears out the program name
;*      that STAT shows.
;*
;*      Usage: CLRPRG jobname
;*
;*      by Dave Heyliger - AMUS Staff
;************************************

       OBJNAM  CLRPRG.LIT              ;Define the final product

       SEARCH SYS                      ;search normal stuff
       SEARCH SYSSYM
       SEARCH TRM

       ;version number
       VMAJOR=1.
       VMINOR=0.
       VEDIT=100.

       ;define variable
       .OFINI
       .OFDEF  BUFFER,8.               ;one variable called BUFFER
       .OFSIZ  IMPSIZ

       ;start of program
       PHDR    -1,0,PH$REE!PH$REU      ;Program is Re-entrant & Re-useable
       GETIMP  IMPSIZ,A5               ;Reg. A5 now ^'s to byte "0" of BUFFER

       LIN                             ;just CLRPRG cr?
       BNE     PACKIT                  ;nope, pack the name
       TYPECR  <Usage: CLRPRG jobname>
       EXIT

       ;A2 should be pointing to JOB name - pack it
PACKIT: LEA     A1,BUFFER(A5)           ;point to buffer variable
       PUSH    A1                      ;save start location
       PACK                            ;pack the name
       PACK
       POP     A1                      ;retrieve start location

       ;get pointer to JCB's
GETTBL: MOV     JOBTBL,A0               ;Get base of JOB TABLE into A0

       ;look for name match
LOOP:   MOV     (A0)+,A4                ;and let A4 point to each JBC
       MOV     A4,D0                   ;this will set the flags 2 B checked
       BMI     EXIT                    ;end of the JOB TABLE on a "-1"
       BEQ     LOOP                    ;goto the top on a "0"
       CMM     JOBNAM(A4),@A1          ;find a match?
       BNE     LOOP                    ;nope, look some more

       ;A4 now IDX for JOB needing the clear
       LEA     A3,SPACES               ;point to spaces
       MOV     @A3,JOBPRG(A4)          ;clear out job program

       ;let the user know you are through
EXIT:   TYPECR <Program name cleared.>
       EXIT                            ;return to AMOS

SPACES: RAD50   /      /

       END