;*************************** AMUS Program Label ******************************
; Filename: JOBMAX.M68/LIT                                  Date: 01/27/89
; Category: UTILITY      Hash Code: 231-536-726-367      Version: 1.0
; Initials: DDSS         Name: Dave Drake
; Company: Double-D Software Services             Telephone #: (702) 438-2173
; Related Files: NONE
; Min. Op. Sys.: 1.3+                         Expertise Level: INT
; Special:
; Description: Command file utility to check if job number > maximum
;               specified on command line (main use is in command/do
;               files. (See Example in source)
;****************************************************************************!
; Copyright (C) 1989 Double-D Software Services.   All Rights Reserved.
;***************************************************************************
;       Double-D Software Services      Dave Drake
;       4924 Chantilly                  (702) 438-2173
;       Las Vegas, Nv. 89110
;
;       PROGRAM NAME: JOBMAX.M68/LIT
;
;       DATE CREATED: 07/07/89
;
;       DESCRIPTION: Job number checker for command/do files
;
;       Example of use in command file:
;
;       .:T
;       .JOBMAX 7/
;       .GOTO ERROR
;       .:<JOB IS ONE OF FIRST 7 JOBS ON SYSTEM>
;       .EXIT
;       .ERROR:
;       .:<JOB IS GREATER THAT 7TH JOB ON JOB LIST>
;       .EXIT
;------------------------------------------------------------------
;       Example of DO file to run Supervue
;
;       :r
;       JOBMAX 7/
;       GOTO ERROR
;       SV $0.T
;       EXIT
;
;       ERROR:
;       XY=0
;       XY 12 20
;       :<Unable to run SuperVUE on this job
;       >
;       XY 13 20
;       :< Press any key to Continue
;       >
;       :k
;       EXIT
;------------------------------------------------------------------------
;       The primary purpose for writing this command was to provide
;       a means to determine if a job was higher than the specified
;       number on the job list.  This provides a means to determine
;       if a job is valid for supervue use before actually getting
;       into supervue.
;
;       The model for this program was LOOKUP.LIT and the syntax is
;       nearly the same.
;
;       USEAGE: JOBMAX n/
;               GOTO LABEL              ;GOTO IF CURRENT JOB NUMBER > n
;
;       CHANGE HISTORY:
;       DATE            BY      DESCRIPTION
;****************************************************************************!
       OBJNAM  JOBMAX.LIT

       SEARCH  SYS
       SEARCH  SYSSYM

       VMAJOR=1.
       VMINOR=0.
       VSUB=0.

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

BEGIN:  JOBIDX  A6                      ; index this job
       MOV     A6,D1                   ; addr in D1
       MOV     JOBTBL,A1               ; index job table
       MOV     #1,D2                   ; start count at 1
$20:    MOV     (A1)+,D3                ; addr to d3
       CMP     D1,D3                   ; is this job?
       BEQ     $30                     ; yes, exit loop
       ADD     #1,D2                   ; no, bump count
       BR      $20                     ; loop
;
; job number in D2
;
$30:    JOBIDX  A4                      ; re index job
       BYP                             ; first printable
       NUM                             ; is numeric
       BNE     DONE                    ; no, error
       GTDEC                           ; yes, convert
       CMP     D1,D2                   ; cur > max
       BHIS    SKPCMD                  ; yes, adjust if command file
       BYP                             ; no, skip to printable
       MOV     A2,A3                   ; save pointer
       LIN                             ; end of line?
       BEQ     DONE                    ; yes, skip
       CMPB    @A2,#'/                 ; no, is slash?
       BNE     $40                     ; no, skip
       INC     A2                      ; yes, go past it
       BYP                             ; find 1st char
$40:    TTYL    @A2                     ; output after slash to term
       CMPB    @A3,#'/                 ; is backslash?
       BEQ     DONE                    ; yes, done
       CLRW    JOBCMZ(A4)                      ; no, clear command execution
       EXIT                            ; done
;
;cur > max adjust command file
;
SKPCMD: BYP                             ; skip to printable
       LIN                             ; end of line?
       BEQ     DONE                    ; yes, done
       CMPB    @A2,#'/                 ; no, is slash?
       BNE     DONE                    ; no, done
       TSTW    JOBCMZ(A4)                      ; yes, are we in a command file?
       BEQ     DONE                    ; no, done
       MOV     JOBBAS(A4),A2           ; yes, index base address
       ADD     JOBSIZ(A4),A2           ; add jobsiz
       SUBW    JOBCMZ(A4),A2           ; sub command file size
$50:    LIN                             ; end of line?
       BEQ     $60                     ; yes, done advancing
       INC     A2                      ; inc cmd file ptr
       DECW    JOBCMZ(A4)              ; dec cmd size ptr
       BR      $50                     ; loop

$60:    INC     A2                      ; first char of next command in cmdfil
       DECW    JOBCMZ(A4)              ; dec execution count
       CMPB    @A2,#15                 ; cr?
       BEQ     DONE                    ; yes, done
       CMPB    @A2,#12                 ; lf?
       BNE     $60                     ; no, loop till done

DONE:   EXIT                            ; done

       END