;*************************** AMUS Program Label ******************************
; Filename: JOBPRG.M68                                      Date: 10/16/89
; Category: SBR          Hash Code: 720-121-764-363      Version:
; Initials:              Name: GARY CHESSER
; Company:                                         Telephone #:
; Related Files: XCALL.M68
; Min. Op. Sys.:                               Expertise Level: BEG
; Special: Must grab XCALL.M68 in 100,133
; Description: Get Jobname from system into a basic program
;
;
;*****************************************************************************
;********************************************************************
; Sample BASIC program:
;
;       MAP1 names(40),S,12             ! 40 is not mandatory. Must be > #JOBS
;
;       XCALL JOBPRG,names(1)           ! note names(1) !!!
;       FOR I = 1 TO 40
;               IF names(I) = "" THEN I = 40 &
;                                ELSE PRINT names(I)
;       NEXT I
;********************************************************************

       OBJNAM  .SBR

       VMAJOR=1
       VMINOR=0


       SEARCH  SYS             ;THESE ARE CALLED IN XCALL      ;search normals
       SEARCH  SYSSYM          ;DITTO GARY CHESSER
       COPY    XCALL                           ;XCALL.M68 in [100,133]

       PHDR    -1,PH$REE!PH$REU

PARSE:  CMPW    XC.ARG(A3),#1           ;1 argument specified?
       BNE     INERR                   ;nope, error
       CMPW    XC.TY1(A3),#XC$STR      ;string?
       BNE     INERR                   ;nope, error
       CMP     XC.SZ1(A3),#6           ;should be this big
       BLT     INERR                   ;nope, error

SETUP:  MOV     JOBTBL,A0               ;get start of job table listing
       MOV     XC.AD1(A3),A2           ;get start of array into A2

LOOP:   MOV     (A0)+,A4                ;A4 points to a JCB or a -1
       MOV     A4,D0                   ;set status register
       BMI     DONE                    ;if -1 then done
       BEQ     LOOP                    ;no attached JOB but still not done
10$:    LEA     A1,JOBNAM(A4)           ;point A1 to RAD50 job name
       UNPACK                          ;unpack 1st half of job name
       UNPACK                          ;unpack 2nd half of job name
20$:    LEA     A1,JOBPRG(A4)           ;point A1 to RAD50 job PROGRAM
       UNPACK                          ;unpack 1st half of job PROGRAM
       UNPACK                          ;unpack 2nd half of job PROGRAM
       BR LOOP                         ;get next JOB

DONE:   CLR     @A2                     ;end array with null
       RTN                             ;and return

INERR:  TYPECR  <Error in entry format for JOBPRG.SBR>
       RTN

       END