Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ZIBCLU0

ZIBCLU0.m

Go to the documentation of this file.
  1. %ZIBCLU0 ; IHS/ADC/GTH - GENERAL PURPOSE CLEAN UP UTILITY GLOBALS ; [ 02/07/97 3:02 PM ]
  1. ;;3.0;IHS/VA UTILITIES;;FEB 07, 1997
  1. EN ;
  1. Q:'($ZV?1"MSM".E!($ZV?1"DSM".E)) ; Only works for MSM or DSM.
  1. S ZIBOS=$ZV ; Set operating system.
  1. D @$S(ZIBOS?1"DSM".E:"DSM",1:"MSM") ; Active JOB lookup per operating system.
  1. D XUT ; Cleanup the ^XUTL global.
  1. F ZIBGR="^ZUT(","^UTILITY(" D GO ; Check the ^ZUT and ^UTILITY globals for nodes to be removed.
  1. D OUT ; KILL off variables and exit gracefully.
  1. Q
  1. ;
  1. MSM ; MSM specific look up of active JOBs.
  1. S $ZT="MER^%ZIBCLU0"
  1. V 44:$J:$ZB($V(44,$J,2),1,7):2
  1. S ZIBST=$V(44),ZIBSTA=$V(ZIBST+8,-3,2)+ZIBST,ZIBMXJ=$V($V(ZIBST+284),-3,4),ZIBPT=$V(3*4+ZIBSTA)
  1. ; Build active JOB table (ZIBJT).
  1. F ZIBJ=1:1:ZIBMXJ S:$V(ZIBJ*4+ZIBPT) ZIBJT(ZIBJ)=$ZU(($V(2,ZIBJ,2)#32),($V(2,ZIBJ,2)\32))
  1. Q
  1. ;
  1. MER ;EP - MSM error trap.
  1. V 44:$J:$ZB($V(44,$J,2),#FFFE,1):2
  1. ZQ
  1. ;
  1. DSM ; DSM specific look up of active JOBs.
  1. S ZIBST=$V(44),ZIBSJT=$V(ZIBST+4)
  1. ; Build active JOB table (ZIBJT).
  1. F ZIBI=ZIBSJT+2:2:ZIBSJT+126 I $V(ZIBI+1),$V(ZIBI+1)'=244 S ZIBJ=ZIBI-ZIBSJT\2 S:ZIBJ]"" ZIBJT(ZIBJ)=$ZU(($V(149,ZIBJ)#32),($V(149,ZIBJ)\32))
  1. S ZIBJT($J)=$ZU(0) ; Put this JOB and UCI in the JOB table.
  1. KILL ZIBSJT
  1. Q
  1. ;
  1. XUT ; Clenaup ^XUTL in MGR separate from other UCIs.
  1. I $ZU(0)?1"MGR".E D
  1. . S ZIBJ=""
  1. . F S ZIBJ=$O(^XUTL("XQ",ZIBJ)) Q:ZIBJ="" KILL:'$D(ZIBJT(ZIBJ)) ^(ZIBJ)
  1. E D
  1. .S ZIBJ=""
  1. .S ZIBK=1 ; Set KILL flag ON - Set OFF if other JOBs active in this UCI
  1. .F S ZIBJ=$O(ZIBJT(ZIBJ)) Q:ZIBJ="" S:ZIBJ'=$J&(ZIBJT(ZIBJ)=$ZU(0)) ZIBK=0
  1. .I ZIBK S ZIBX="" F S ZIBX=$O(^XUTL(ZIBX)) Q:ZIBX="" KILL ^(ZIBX)
  1. Q
  1. ;
  1. GO ; $O down ^ZUT or ^UTILITY looking for (jobnbr OR (namespace,jobnbr
  1. S ZIBX1=""
  1. F S (ZIBA,ZIBJ,ZIBX1)=$O(@(ZIBGR_""""_ZIBX1_""")")) Q:ZIBX1="" D @$S(ZIBX1?1N.N:"N1",1:"N2")
  1. GOQ ;
  1. Q
  1. ;
  1. N1 ; Check first subscript value and remove if its a dangling node.
  1. I ZIBOS?1"MSM".E,ZIBX1="%ER" D N2 G N1Q
  1. D RM
  1. N1Q ;
  1. Q
  1. ;
  1. N2 ; Process second node if first is non-numeric or ^UTILITY("%ER" for MSM
  1. S ZIBX2="",ZIBA1=""""_ZIBA_""""
  1. F ZIBI=1:1 S ZIBRM=1,ZIBX2=$O(@(ZIBGR_""""_ZIBX1_""","""_ZIBX2_""")")) D D:ZIBRM RM Q:ZIBX2=""
  1. .I ZIBOS?1"MSM".E,ZIBX1="%ER",($P($H,",")-ZIBX2)<7 S ZIBRM=0 Q
  1. .I ZIBX2]"" S ZIBA=ZIBA1_","""_ZIBX2_"""",ZIBJ=ZIBX2
  1. KILL ZIBRM
  1. Q
  1. ;
  1. RM ; Remove dangling ^UTILITY node.
  1. ; If not in active JOB table '$D(ZIBJT(ZIBJ))
  1. ; Or if an active JOB and not this UCI $D(ZIBJT(ZIBJ) & ZIBJT(ZIBJ)'=$Z(0)
  1. ; Or if an active JOB and this UCI, but the same $J as this JOB.
  1. I $D(ZIBJT(ZIBJ)),ZIBJT(ZIBJ)=$ZU(0),$J'=ZIBJ G RMQ
  1. KILL @(ZIBGR_ZIBA_")") ; Remove dangling ^ZUT or ^UTILITY node.
  1. RMQ ;
  1. Q
  1. ;
  1. OUT ;
  1. KILL ZIBOS,ZIBA,ZIBA1,ZIBX1,ZIBX2,ZIBST,ZIBJT,ZIBJM,ZIBJI,ZIBJ,ZIBQ,ZIBGR,ZIBSTA,ZIBMXJ,ZIBPT,ZIBK
  1. I $ZV?1"MSM".E V 44:$J:$ZB($V(44,$J,2),#FFFE,1):2
  1. Q
  1. ;