From:	MERC::"uunet!CRVAX.SRI.COM!RELAY-INFO-VAX" 12-APR-1992 20:34:07.36
To:	info-vax@kl.sri.com
CC:	
Subj:	Re: How to use f$getqui

Here's another version of this -- it allows you to specify a username
and/or queue name to match:


$! ------------------ CUT HERE -----------------------
$ v='f$verify(f$trnlnm("SHARE_VERIFY"))'
$!
$! This archive created by VMS_SHARE Version 7.2-007  22-FEB-1990
$!   On 29-OCT-1990 17:08:47.03   By user RLB 
$!
$! This VMS_SHARE Written by:
$!    Andy Harper, Kings College London UK
$!
$! Acknowledgements to:
$!    James Gray       - Original VMS_SHARE
$!    Michael Bednarek - Original Concept and implementation
$!
$! TO UNPACK THIS SHARE FILE, CONCATENATE ALL PARTS IN ORDER
$! AND EXECUTE AS A COMMAND PROCEDURE  (  @name  )
$!
$! THE FOLLOWING FILE(S) WILL BE CREATED AFTER UNPACKING:
$!       1. FINDJOB.COM;25
$!
$set="set"
$set symbol/scope=(nolocal,noglobal)
$f=f$parse("SHARE_TEMP","SYS$SCRATCH:.TMP_"+f$getjpi("","PID"))
$e="write sys$error  ""%UNPACK"", "
$w="write sys$output ""%UNPACK"", "
$ if f$trnlnm("SHARE_LOG") then $ w = "!"
$ ve=f$getsyi("version")
$ if ve-f$extract(0,1,ve) .ges. "4.4" then $ goto START
$ e "-E-OLDVER, Must run at least VMS 4.4"
$ v=f$verify(v)
$ exit 44
$UNPACK: SUBROUTINE ! P1=filename, P2=checksum
$ if f$search(P1) .eqs. "" then $ goto file_absent
$ e "-W-EXISTS, File ''P1' exists. Skipped."
$ delete 'f'*
$ exit
$file_absent:
$ if f$parse(P1) .nes. "" then $ goto dirok
$ dn=f$parse(P1,,,"DIRECTORY")
$ w "-I-CREDIR, Creating directory ''dn'."
$ create/dir 'dn'
$ if $status then $ goto dirok
$ e "-E-CREDIRFAIL, Unable to create ''dn'. File skipped."
$ delete 'f'*
$ exit
$dirok:
$ w "-I-PROCESS, Processing file ''P1'."
$ if .not. f$verify() then $ define/user sys$output nl:
$ EDIT/TPU/NOSEC/NODIS/COM=SYS$INPUT 'f'/OUT='P1'
PROCEDURE Unpacker ON_ERROR ENDON_ERROR;SET(FACILITY_NAME,"UNPACK");SET(
SUCCESS,OFF);SET(INFORMATIONAL,OFF);f:=GET_INFO(COMMAND_LINE,"file_name");b:=
CREATE_BUFFER(f,f);p:=SPAN(" ")@r&LINE_END;POSITION(BEGINNING_OF(b));
LOOP EXITIF SEARCH(p,FORWARD)=0;POSITION(r);ERASE(r);ENDLOOP;POSITION(
BEGINNING_OF(b));g:=0;LOOP EXITIF MARK(NONE)=END_OF(b);x:=ERASE_CHARACTER(1);
IF g=0 THEN IF x="X" THEN MOVE_VERTICAL(1);ENDIF;IF x="V" THEN APPEND_LINE;
MOVE_HORIZONTAL(-CURRENT_OFFSET);MOVE_VERTICAL(1);ENDIF;IF x="+" THEN g:=1;
ERASE_LINE;ENDIF;ELSE IF x="-" THEN IF INDEX(CURRENT_LINE,"+-+-+-+-+-+-+-+")=
1 THEN g:=0;ENDIF;ENDIF;ERASE_LINE;ENDIF;ENDLOOP;t:="0123456789ABCDEF";
POSITION(BEGINNING_OF(b));LOOP r:=SEARCH("`",FORWARD);EXITIF r=0;POSITION(r);
ERASE(r);x1:=INDEX(t,ERASE_CHARACTER(1))-1;x2:=INDEX(t,ERASE_CHARACTER(1))-1;
COPY_TEXT(ASCII(16*x1+x2));ENDLOOP;WRITE_FILE(b,GET_INFO(COMMAND_LINE,
"output_file"));ENDPROCEDURE;Unpacker;QUIT;
$ delete/nolog 'f'*
$ CHECKSUM 'P1'
$ IF CHECKSUM$CHECKSUM .eqs. P2 THEN $ EXIT
$ e "-E-CHKSMFAIL, Checksum of ''P1' failed."
$ ENDSUBROUTINE
$START:
$ create 'f'
X$! FINDJOB.COM, VMS V5 compatible version
X$!
X$! Look in specified queue(s) to find a particular job with various`20
X$! specifiers:  may include username and job status types
X$!
X$! p1 -- job name
X$! p2 -- queue name
X$! p3 -- username (optional)
X$! p4 -- global symbol to return entry number to
X$! p5 -- qualifiers -- such as pending_jobs,holding_jobs,...etc.
X$!
X$ vfl = f$verify(0+f$trnlnm("debug$dcl"))
X$ null = ""`20
X$ search$_nomatch = "%X08D78053"
X$ jbc$_nosuchjob = %X00048042
X$ match_job = p1
X$ match_queue = p2
X$ if match_queue.eqs.null then $ match_queue = "*"
X$ match_user = f$edit(p3,"trim,upcase,compress")
X$ my_user = f$edit(f$getjpi("","username"),"trim,compress")
X$
X$ return_symbol = p4
X$ job_flags = "all_jobs"
X$ if p5.nes."" then $ job_flags = job_flags+","+p5
X$! if (match_user.nes."") .and. (my_user.nes.match_user) then -
X$! `09job_flags = job_flags+",all_jobs"
X$ freeze_flags = "freeze_context,all_jobs"
X$ tmp = f$getqui("CANCEL_OPERATION")
X$! establish queue context
X$QUEUE_LOOP:
X$ nxt_queue = f$getqui("display_queue","queue_name",match_queue,"BATCH,wildc
Vard")
X$ if nxt_queue.nes.null
X$ then
X$  if f$ver() then $ show symbol NXT_QUEUE
X$JOB_LOOP:
X$  job_entry = f$getqui("display_job","entry_number",,job_flags)
X$  if job_entry.eqs.null then $ goto QUEUE_LOOP
X$  job_name = f$getqui("display_job","job_name",,freeze_flags)
X$  if match_job.nes.null
X$  then
X$`09if f$loc(match_job,job_name).ge.f$length(job_name) then $ goto JOB_LOOP
X$  endif ! job name check
X$  if match_user.nes.null`20
X$  then
X$`09job_user =f$getqui("display_job","username",,freeze_flags)
X$`09if f$ver() then $ show symbol job_user
X$`09job_user = f$edit(job_user,"trim,compress")
X$`09if f$loc(match_user,job_user).ge.f$length(job_user) then $ goto JOB_LOOP
X$  endif ! user check
X$! we seem to have found a job that qualifies
X$  if return_symbol.nes.null then $ 'return_symbol' == job_entry
X$  status = $status
X$ else
X$  status = jbc$_nosuchjob
X$ endif
X$EXIT:
X$ tmp = f$getqui("cancel_operation")+f$ver(vfl)
X$ exit status
X$!Last Modified:  24-APR-1989 08:56:58.78, By: RLB`20
$ CALL UNPACK FINDJOB.COM;25 1497519876
$ v=f$verify(v)
$ EXIT
--

Bob Boyd                 
rbn@ralph.rtpnc.epa.gov 
Unisys/EPA               

