XUPSUTQ ;EDS/GRR - QUEUEING UTILITY (%ZTLOAD) ; 16-JUL-03
 ;;8.0;KERNEL;**309**;Jul 10, 1995
 ;
Q1 S ZTDTH=$H
QUE K IO("Q") I '$D(ZTIO),$D(ION),ION="" S ZTIO=""
 I '$D(ZTDESC) S ZTDESC=$S($D(XUPSPGM):XUPSPGM,$D(PGM):PGM,1:"KERNEL UNKNOWN OPTION")
 I '$D(ZTRTN) S ZTRTN=$S($D(XUPSPGM):XUPSPGM,$D(PGM):PGM,1:"") G:XUPSPGM="" CLOSE S ZTRTN="DQ^XUPSUTQ"
 I $D(XUPSPGM),'$D(ZTLOAD(XUPSPGM)) S ZTSAVE("XUPSPGM")=""
LOAD D ^%ZTLOAD W !!,$S($D(ZTSK):"Request Queued!",1:"Request Cancelled!") S:'$D(ZTSK) X="^" S:$D(ZTSK) X="" G CLOSE:$D(ZTSK),END
 Q
ZIS W ! K IOP,IO("Q") S POP=0,%ZIS="QMP" D ^%ZIS K %ZIS,IOP Q:POP  I $D(IO("Q")) D QUE S POP=1 G CLOSE
 U IO
 Q
CLOSE Q:$D(ZTQUEUED)  N POP D ^%ZISC
END K ZTSK,ZTDESC,ZTRTN,ZTREQ,ZTSAVE,ZTIO,ZTDTH,ZTUCI,XUPSPGM,PGM,IO("Q"),IO("C")
 Q
DQ D @($S($D(XUPSPGM):XUPSPGM,$D(PGM):PGM,1:"CLOSE"))
 D KILL^%ZTLOAD,CLOSE
 Q
DTQ N XUPSX,Z,X,%H I $D(ZTSK("D")) S XUPSX=ZTSK("D"),%H=$P(XUPSX,",") D YMD^%DTC S XUPSX=$P(XUPSX,",",2),Z=X_((XUPSX#3600\60)/100+(XUPSX\3600)/100) ;Find time queued
 Q
