AZQZTMK ;IHS/MFD ;NON-INTERACTIVE KILL OFF TM QUEUE ; 12/16/88 5:38 PM
;SCHEDULE WITH TASKMAN TO AUTOMATICALLY CLEAN %ZTSK GLOBAL
;SET ZTKF TO NUMBER OF DAYS BACK TO SAVE
S ZTKF=1,U="^"
DQ S DS="" F I=0:0 S DS=$O(^%ZTSCH(DS)) Q:DS="" S ZTSK="" F J=0:0 S ZTSK=$O(^%ZTSCH(DS,ZTSK)) Q:ZTSK="" I $D(^%ZTSK(ZTSK,0)) S $P(^(0),U,6)=DS
;
S ZTSN=0,ZTMX=^%ZTSK(0)-10,ZTDT=$H-ZTKF
A1 S ZTSN=$N(^%ZTSK(ZTSN)) G END:ZTSN'?1N.N
I ZTSN>ZTMX S ZTSN=100+^%ZTSK(0),ZTMX=9999999999 G A1
L ^%ZTSK S X=$S($D(^%ZTSK(ZTSN,0)):^(0),1:"") L
S DL=+$P(X,"^",5),DR=+$P(X,"^",6),DC=+$P(X,"^",7),DS=+$P(X,"^",8)
I DS G A1:+$H<DS,A2
S:'DC DC=DR S:'DC DC=DL G A1:DC>ZTDT
A2 K ^%ZTSK(ZTSN) G A1
END I ^%ZTSK(0)>99999999 L ^%ZTSK S ^%ZTSK(0)=1000 L
KIL K ZTSK,ZTSN,ZTKF,ZTMX,ZTDT,DL,DR,DC,DS
Q
AZQZTMK ;IHS/MFD ;NON-INTERACTIVE KILL OFF TM QUEUE ; 12/16/88 5:38 PM
+1 ;SCHEDULE WITH TASKMAN TO AUTOMATICALLY CLEAN %ZTSK GLOBAL
+2 ;SET ZTKF TO NUMBER OF DAYS BACK TO SAVE
+3 SET ZTKF=1
SET U="^"
DQ SET DS=""
FOR I=0:0
SET DS=$ORDER(^%ZTSCH(DS))
IF DS=""
QUIT
SET ZTSK=""
FOR J=0:0
SET ZTSK=$ORDER(^%ZTSCH(DS,ZTSK))
IF ZTSK=""
QUIT
IF $DATA(^%ZTSK(ZTSK,0))
SET $PIECE(^(0),U,6)=DS
+1 ;
+2 SET ZTSN=0
SET ZTMX=^%ZTSK(0)-10
SET ZTDT=$HOROLOG-ZTKF
A1
*** ERROR ***
SET ZTSN=$N(^%ZTSK(ZTSN))
IF ZTSN'?1N.N
GOTO END
+1 IF ZTSN>ZTMX
SET ZTSN=100+^%ZTSK(0)
SET ZTMX=9999999999
GOTO A1
+2 LOCK ^%ZTSK
SET X=$SELECT($DATA(^%ZTSK(ZTSN,0)):^(0),1:"")
LOCK
+3 SET DL=+$PIECE(X,"^",5)
SET DR=+$PIECE(X,"^",6)
SET DC=+$PIECE(X,"^",7)
SET DS=+$PIECE(X,"^",8)
+4 IF DS
IF +$HOROLOG<DS
GOTO A1
GOTO A2
+5 IF 'DC
SET DC=DR
IF 'DC
SET DC=DL
IF DC>ZTDT
GOTO A1
A2 KILL ^%ZTSK(ZTSN)
GOTO A1
END IF ^%ZTSK(0)>99999999
LOCK ^%ZTSK
SET ^%ZTSK(0)=1000
LOCK
KIL KILL ZTSK,ZTSN,ZTKF,ZTMX,ZTDT,DL,DR,DC,DS
+1 QUIT