;*************************** AMUS Program Label ******************************
; Filename: PROGS.SBR Date: 04/20/90
; Category: UTIL Hash Code: 522-273-702-257 Version: 1.1(102)
; Initials: ULTR/US Name: DAVID PALLMANN
; Company: ULTRASOFT CORPORATION Telephone #: 5163484848
; Related Files:
; Min. Op. Sys.: AMOSL 1.3B/AMOS32 1.0 Expertise Level: BEG
; Special:
; Description: Return program names (and, optionally, job names, and now user
; names) to BASIC.
;*****************************************************************************
;****************************************************************************
;* *
;* PROGS.SBR *
;* AlphaBASIC XCALL to return program names of all jobs on the system *
;* *
;****************************************************************************
;Copyright (C) 1990 UltraSoft Corporation. All Rights Reserved.
; Username code added Copyleft 1993 Bob Rubendunst, Soft Machines.
;
; MAP1 JOB'COUNT, F, 6
; MAP1 PROG'NAME(x), S, 6
; MAP1 JOB'NAME(x), S, 6 <- optional
; MAP1 USER'NAME(x), S, 20 <- also optional
; ...
; XCALL PROGS, JOB'COUNT, PROG'NAME(1) {,JOB'NAME(1)} {,USER'NAME(1)}
;
; sets JOB'COUNT to the number of jobs on the system
; returns PROG'NAME(1) through PROG'NAME(JOB'COUNT) with program names
;
; if specified, JOB'NAME(1) through JOB'NAME(JOB'COUNT) receives the
; name of each job. This third parameter is optional.
;
; if specified, USER'NAME(1) through USER'NAME(JOB'COUNT) receives the
; name of each job. This third parameter is optional.
;
;Written by: David Pallmann
;
;Edit History:
;1.0(100) 29-Aug-90 created. /DFP
;1.1(101) 12-Dec-90 add optional third argument to return job names. /DFP
;[102] 20 April 1993 15:05 Edited by Bob Rubendunst, Soft Machines.
; Added user name array code.
;
CHECK: CMPW X.ARGS(A3),#2 ; 2 or more arguments supplied? [101]
JLO CNTERR ; no - error [101]
CMPW X.TYP1(A3),#X.FLT ; arg 1 floating point?
JNE TYPERR ; no - error
MOVW X.TYP2(A3),D7 ; get 2nd argument type
ANDW #^C<X.ARY>,D7 ; clear array bit
CMPW D7,#X.STR ; arg 2 string?
JNE TYPERR ; no - error
CMPW X.ARGS(A3),#3 ; are there 3 arguments?
BLO 10$ ; no
MOVW X.TYP3(A3),D7 ; get 3rd argument type
ANDW #^C<X.ARY>,D7 ; clear array bit
CMPW D7,#X.STR ; arg 3 string?
JNE TYPERR ; no - error
MOV X.ADR3(A3),A4 ; set index A4
CMPW X.ARGS(A3),#4 ; are there 4 arguments?
BLO 10$ ; no
MOVW X.TYP4(A3),D7 ; get 4th argument type
ANDW #^C<X.ARY>,D7 ; clear array bit
CMPW D7,#X.STR ; arg 4 string?
JNE TYPERR ; no - error
MOV X.ADR4(A3),D2 ; set index D2
;index job table, initialize job count, and set index to array
10$: MOV JOBTBL,A0 ; index jobn table
CLR D5 ; clear job count
MOV X.ADR2(A3),A2 ; index return array
;main loop of program
LOOP: MOV (A0)+,D7 ; get next JCB address
BEQ LOOP ; deallocated job
CMP D7,#-1 ; end of job table?
JEQ RETURN ; yes
MOV D7,A6 ;
INC D5 ; update job count
;check for job at AMOS command level
MOV A6,D4 ; save JCB address for later
MOVW JOBSTS(A6),D6 ; get job status
ANDW #J.MON,D6 ; at AMOS command level?
BNE CLRPRG ; yes - return empty string
;convert program name to ASCII
LEA A1,JOBPRG(A6) ; index program name
UNPACK ; return
UNPACK ; program name
CALL TRIM ; remove trailing spaces [101]
BR CHKJOB ; [101]
SAVE A2 ; save registers [101]
MOV A4,A2 ; set-up A2 for UNPACKing [101]
MOV D4,A6 ; restore JCB address [101]
LEA A1,JOBNAM(A6) ; index program name [101]
UNPACK ; return [101]
UNPACK ; program name [101]
CALL TRIM ; remove trailing spaces [101]
MOV A2,A4 ; put back in A4 so we remember [101]
REST A2 ; restore registers [101]
SAVE A2
MOV D2,A2 ; use A2 as index
; copy user name to array [102]
MOV #19.,D0 ; get max size of username field
MOV X.SIZ4(A3),D1 ; get size of array element
MOV D4,A6 ; index jcb
LEA A6,JOBUSN(A6) ; index job user name (null terminated)
20$: MOVB (A6)+,D7 ; get a byte
BEQ 40$ ; end of username.
MOVB D7,(A2)+ ; copy to array
DEC D1 ; count down element bytes remaining
BEQ 40$ ; end of element
SOB D0,20$ ; until whole name scanned or null
40$: TST D1 ; room for null?
BEQ 60$ ; no, done
CLRB (A2)+ ; yes, append null to terminate string
DEC D1 ; count while we null & space out
BR 40$ ; and loop till we hit next element
60$: MOV A2,D2 ; save array ptr for next elemnet
REST A2 ; end [102]
JMP LOOP ; [101]