XUTMTR2 ;SEA/RDS - TaskMan: ToolKit, Report 2 (Status & Stop) ;05/26/98 16:42
;;8.0;KERNEL;**86**;Jul 10, 1995
;
TASK ;Lookup Task File Data And Set Stop Flag
L +^%ZTSK(XUTMT) I '$D(^%ZTSK(XUTMT)),'$D(^%ZTSCH("TASK",XUTMT)) W !,"Task # ",XUTMT," does not exist." G NOPE
I $D(^%ZTSK(XUTMT,0))[0,'$D(^%ZTSCH("TASK",XUTMT)) W !,"Task # ",XUTMT," does exist, but is missing critical data." G NOPE
S ZTSK=XUTMT,ZTSK(0)=$S($D(^%ZTSK(ZTSK,0))#2:^(0),1:""),ZTSK(.1)=$S($D(^(.1))#2:^(.1),1:""),ZTSK(.2)=$S($D(^(.2))#2:^(.2),1:""),ZTSK(.26)=$S($D(^(.26))#2:^(.26),1:"")
N %,%D,%H,%M,%Y,%ZTT,X,Y,ZT,ZT1,ZT2,ZT3,ZTC,ZTUNSCH S $P(^%ZTSK(ZTSK,.1),U,10)=ZTNAME,ZTUNSCH=0
;
SCHED ;Lookup Task In Schedule File And Unschedule Task
S ZT1="" F ZT=0:0 S ZT1=$O(^%ZTSCH(ZT1)) Q:'ZT1 I $D(^%ZTSCH(ZT1,ZTSK))#2 S ZTSK("A",ZT1,ZTSK)="",ZT2=^(ZTSK),ZTUNSCH=1 K ^%ZTSCH(ZT1,ZTSK) I ZT2]"" S $P(^%ZTSK(ZTSK,.2),U)=ZT2,$P(ZTSK(.2),U)=ZT2
S ZT1=""
F ZT=0:0 S ZT1=$O(^%ZTSCH("IO",ZT1)),ZT2="" Q:ZT1="" F ZT=0:0 S ZT2=$O(^%ZTSCH("IO",ZT1,ZT2)) Q:ZT2="" I $D(^(ZT2,ZTSK))#2 S ZTSK("IO",ZT1,ZT2,ZTSK)="",ZTUNSCH=1 D DQIO
S ZT1="" F ZT=0:0 S ZT1=$O(^%ZTSCH("JOB",ZT1)) Q:ZT1="" I $D(^(ZT1,ZTSK))#2 S ZTSK("JOB",ZT1,ZTSK)="",ZTUNSCH=1 K ^(ZTSK)
S ZT1="" F ZT=0:0 S ZT1=$O(^%ZTSCH("LINK",ZT1)),ZT2="" Q:ZT1="" F ZT=0:0 S ZT2=$O(^%ZTSCH("LINK",ZT1,ZT2)) Q:ZT2="" I $D(^(ZT2,ZTSK))#2 S ZTSK("LINK",ZT1,ZT2,ZTSK)="",ZTUNSCH=1 K ^(ZTSK)
S:$D(^%ZTSCH("TASK",ZTSK))#2 ZTSK("TASK",ZTSK)=^(ZTSK) S:ZTUNSCH $P(^%ZTSK(ZTSK,.1),U,1,3)="F^"_$H_U_ZTNAME
L -^%ZTSK(XUTMT)
;
REPORT ;Report Results Of Lookup And Stop
I $D(ZTSK("TASK",ZTSK)) W !,"This task has already started running, but it has been asked to stop." W:$D(^%ZTSK(ZTSK,0))[0 !?5,"The task's record is missing critical data." K XUTMT Q
I $O(ZTSK(.3))]"" W !,"Task unscheduled and stopped." K XUTMT Q
I "1356ABCDEFGIL"[$P(ZTSK(.1),U) W !,"This task was already stopped." K XUTMT Q
W !,"Task stopped!" K XUTMT Q
;
DQIO ;Remove A Device Waiting List Entry
N %ZTIO,ZTDTH S %ZTIO=ZT1,ZTDTH=ZT2 L +^%ZTSK(ZTSK),+^%ZTSCH("IO") D DQ^%ZTM4 L -^%ZTSCH("IO"),-^%ZTSK(ZTSK) Q
;
NOPE L -^%ZTSK(XUTMT) K XUTMT Q
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HXUTMTR2 2168 printed Dec 13, 2024@02:13:57 Page 2
XUTMTR2 ;SEA/RDS - TaskMan: ToolKit, Report 2 (Status & Stop) ;05/26/98 16:42
+1 ;;8.0;KERNEL;**86**;Jul 10, 1995
+2 ;
TASK ;Lookup Task File Data And Set Stop Flag
+1 LOCK +^%ZTSK(XUTMT)
IF '$DATA(^%ZTSK(XUTMT))
IF '$DATA(^%ZTSCH("TASK",XUTMT))
WRITE !,"Task # ",XUTMT," does not exist."
GOTO NOPE
+2 IF $DATA(^%ZTSK(XUTMT,0))[0
IF '$DATA(^%ZTSCH("TASK",XUTMT))
WRITE !,"Task # ",XUTMT," does exist, but is missing critical data."
GOTO NOPE
+3 SET ZTSK=XUTMT
SET ZTSK(0)=$SELECT($DATA(^%ZTSK(ZTSK,0))#2:^(0),1:"")
SET ZTSK(.1)=$SELECT($DATA(^(.1))#2:^(.1),1:"")
SET ZTSK(.2)=$SELECT($DATA(^(.2))#2:^(.2),1:"")
SET ZTSK(.26)=$SELECT($DATA(^(.26))#2:^(.26),1:"")
+4 NEW %,%D,%H,%M,%Y,%ZTT,X,Y,ZT,ZT1,ZT2,ZT3,ZTC,ZTUNSCH
SET $PIECE(^%ZTSK(ZTSK,.1),U,10)=ZTNAME
SET ZTUNSCH=0
+5 ;
SCHED ;Lookup Task In Schedule File And Unschedule Task
+1 SET ZT1=""
FOR ZT=0:0
SET ZT1=$ORDER(^%ZTSCH(ZT1))
if 'ZT1
QUIT
IF $DATA(^%ZTSCH(ZT1,ZTSK))#2
SET ZTSK("A",ZT1,ZTSK)=""
SET ZT2=^(ZTSK)
SET ZTUNSCH=1
KILL ^%ZTSCH(ZT1,ZTSK)
IF ZT2]""
SET $PIECE(^%ZTSK(ZTSK,.2),U)=ZT2
SET $PIECE(ZTSK(.2),U)=ZT2
+2 SET ZT1=""
+3 FOR ZT=0:0
SET ZT1=$ORDER(^%ZTSCH("IO",ZT1))
SET ZT2=""
if ZT1=""
QUIT
FOR ZT=0:0
SET ZT2=$ORDER(^%ZTSCH("IO",ZT1,ZT2))
if ZT2=""
QUIT
IF $DATA(^(ZT2,ZTSK))#2
SET ZTSK("IO",ZT1,ZT2,ZTSK)=""
SET ZTUNSCH=1
DO DQIO
+4 SET ZT1=""
FOR ZT=0:0
SET ZT1=$ORDER(^%ZTSCH("JOB",ZT1))
if ZT1=""
QUIT
IF $DATA(^(ZT1,ZTSK))#2
SET ZTSK("JOB",ZT1,ZTSK)=""
SET ZTUNSCH=1
KILL ^(ZTSK)
+5 SET ZT1=""
FOR ZT=0:0
SET ZT1=$ORDER(^%ZTSCH("LINK",ZT1))
SET ZT2=""
if ZT1=""
QUIT
FOR ZT=0:0
SET ZT2=$ORDER(^%ZTSCH("LINK",ZT1,ZT2))
if ZT2=""
QUIT
IF $DATA(^(ZT2,ZTSK))#2
SET ZTSK("LINK",ZT1,ZT2,ZTSK)=""
SET ZTUNSCH=1
KILL ^(ZTSK)
+6 if $DATA(^%ZTSCH("TASK",ZTSK))#2
SET ZTSK("TASK",ZTSK)=^(ZTSK)
if ZTUNSCH
SET $PIECE(^%ZTSK(ZTSK,.1),U,1,3)="F^"_$HOROLOG_U_ZTNAME
+7 LOCK -^%ZTSK(XUTMT)
+8 ;
REPORT ;Report Results Of Lookup And Stop
+1 IF $DATA(ZTSK("TASK",ZTSK))
WRITE !,"This task has already started running, but it has been asked to stop."
if $DATA(^%ZTSK(ZTSK,0))[0
WRITE !?5,"The task's record is missing critical data."
KILL XUTMT
QUIT
+2 IF $ORDER(ZTSK(.3))]""
WRITE !,"Task unscheduled and stopped."
KILL XUTMT
QUIT
+3 IF "1356ABCDEFGIL"[$PIECE(ZTSK(.1),U)
WRITE !,"This task was already stopped."
KILL XUTMT
QUIT
+4 WRITE !,"Task stopped!"
KILL XUTMT
QUIT
+5 ;
DQIO ;Remove A Device Waiting List Entry
+1 NEW %ZTIO,ZTDTH
SET %ZTIO=ZT1
SET ZTDTH=ZT2
LOCK +^%ZTSK(ZTSK),+^%ZTSCH("IO")
DO DQ^%ZTM4
LOCK -^%ZTSCH("IO"),-^%ZTSK(ZTSK)
QUIT
+2 ;
NOPE LOCK -^%ZTSK(XUTMT)
KILL XUTMT
QUIT