AURXREF ; RE-XREF SELECTED XREFS [ 10/27/87 8:31 AM ]
; EDE/10-12-87
;
; This routine re-xrefs selected cross references for
; a file. The xrefs are killed at the highest level and
; then reset. This is very different from what FileMan does when
; you RE-INDEX a field. FileMan does a logical kill and then sets
; the new xrefs. The reason for this is multiple fields may set the
; same xref so you would want to kill only the ones set by the
; field being RE-INDEXed.
;
; You must re-xref all fields that set any one of the xrefs being
; killed and reset, unless the xref is set the same from multiple
; fields. Very hard to explain. If you do not understand the
; problem, you probably shouldn't be running this routine.
;
; This routine executes an entry point in ^DIK to build the xref
; logic for all xrefs on the file. It then deletes the logic
; for all xrefs not selected, and executes another entry point
; in ^DIK to actually xref the file.
;
; TRIGGERS are very complex animals, which do not have a xref to kill
; plus may be conditional and may have no affect on the SET side
; at all. Because of the uncertainties here this routine will not
; do TRIGGERS.
;
; Xrefs at the multiple level would require a $O through the data
; global to kill, therefore, sub-file xrefs are not selectable
; unless they are cross-referenced to the whole file.
;
START ;
D INIT^AURXREF2 ; Do initialization
D GETFILE^AURXREF2 ; Get file to be RE-XREFed
I AURXREF("QFLG") D EOJ Q
D BLDXRT^AURXREF2 ; Build xref table
I AURXREF("QFLG") D EOJ Q
D CONFIRM^AURXREF2 ; Get confirmation from user
I AURXREF("QFLG") D EOJ Q
D SETUP ; Set up xrefs for ^DIK
D KILL ; Kill xrefs
D XREF ; For each entry, set xrefs
D EOJ ; Clean up
Q
;
SETUP ; SETUP XREFS FOR ^DIK
S DIK=AURXREF("GBL"),X=1 D DD^DIK
S AURXREF("DIK FILE")="" F AURXREF("L")=0:0 S AURXREF("DIK FILE")=$O(^UTILITY("DIK",$J,AURXREF("DIK FILE"))) Q:AURXREF("DIK FILE")="" D SETUPB
Q
;
SETUPB ; KILL OFF DIK FILE/SUB-FILES NOT NEEDED
I '$D(^UTILITY("AURXREF",$J,AURXREF("DIK FILE"))) K ^UTILITY("DIK",$J,AURXREF("DIK FILE")) Q
S AURXREF("DIK FIELD")="" F AURXREF("L")=0:0 S AURXREF("DIK FIELD")=$O(^UTILITY("DIK",$J,AURXREF("DIK FILE"),AURXREF("DIK FIELD"))) Q:AURXREF("DIK FIELD")="" D SETUPC
Q
;
SETUPC ; KILL OFF DIK FIELDS NOT NEEDED
I '$D(^UTILITY("AURXREF",$J,AURXREF("DIK FILE"),AURXREF("DIK FIELD"))) K ^UTILITY("DIK",$J,AURXREF("DIK FILE"),AURXREF("DIK FIELD")) Q
S AURXREF("DIK XREF")=0 F AURXREF("L")=0:0 S AURXREF("DIK XREF")=$O(^UTILITY("DIK",$J,AURXREF("DIK FILE"),AURXREF("DIK FIELD"),AURXREF("DIK XREF"))) Q:AURXREF("DIK XREF")="" D SETUPD
Q
;
SETUPD ; KILL OFF DIK XREFS NOT NEEDED
I '$D(^UTILITY("AURXREF",$J,AURXREF("DIK FILE"),AURXREF("DIK FIELD"),AURXREF("DIK XREF"))) K ^UTILITY("DIK",$J,AURXREF("DIK FILE"),AURXREF("DIK FIELD"),AURXREF("DIK XREF")) Q
Q
;
KILL ; KILL XREFS
S AURXREF("FILE")="" F AURXREF("L")=0:0 S AURXREF("FILE")=$O(^UTILITY("AURXREF",$J,AURXREF("FILE"))) Q:AURXREF("FILE")="" D KILL2
Q
;
KILL2 ;
S AURXREF("FIELD")="" F AURXREF("L")=0:0 S AURXREF("FIELD")=$O(^UTILITY("AURXREF",$J,AURXREF("FILE"),AURXREF("FIELD"))) Q:AURXREF("FIELD")="" D KILL3
Q
KILL3 ;
S AURXREF("XREF")="" F AURXREF("L")=0:0 S AURXREF("XREF")=$O(^UTILITY("AURXREF",$J,AURXREF("FILE"),AURXREF("FIELD"),AURXREF("XREF"))) Q:AURXREF("XREF")="" D KILL4
Q
;
KILL4 ;
S X=^(AURXREF("XREF"))
W !,"Killing ",X K @(AURXREF("GBL")_"X)")
Q
;
XREF ; SET XREFS FOR ALL ENTRIES
D NOW^%DTC S Y=% X ^DD("DD") W !!,"Beginning run at ",$P(Y,"@",2)," <WAIT>"
S (DA,DCNT)=0 D CNT^DIK1
Q
;
EOJ ; EOJ HOUSEKEEPING
I 'AURXREF("QFLG") D NOW^%DTC S Y=% X ^DD("DD") W !!,"Finished run at ",$P(Y,"@",2)
K AURXREF
K %,%H,%I,DA,DIC,DIK,X,Y
K ^UTILITY("AURXREF",$J),^UTILITY("DIK",$J)
Q
AURXREF ; RE-XREF SELECTED XREFS [ 10/27/87 8:31 AM ]
+1 ; EDE/10-12-87
+2 ;
+3 ; This routine re-xrefs selected cross references for
+4 ; a file. The xrefs are killed at the highest level and
+5 ; then reset. This is very different from what FileMan does when
+6 ; you RE-INDEX a field. FileMan does a logical kill and then sets
+7 ; the new xrefs. The reason for this is multiple fields may set the
+8 ; same xref so you would want to kill only the ones set by the
+9 ; field being RE-INDEXed.
+10 ;
+11 ; You must re-xref all fields that set any one of the xrefs being
+12 ; killed and reset, unless the xref is set the same from multiple
+13 ; fields. Very hard to explain. If you do not understand the
+14 ; problem, you probably shouldn't be running this routine.
+15 ;
+16 ; This routine executes an entry point in ^DIK to build the xref
+17 ; logic for all xrefs on the file. It then deletes the logic
+18 ; for all xrefs not selected, and executes another entry point
+19 ; in ^DIK to actually xref the file.
+20 ;
+21 ; TRIGGERS are very complex animals, which do not have a xref to kill
+22 ; plus may be conditional and may have no affect on the SET side
+23 ; at all. Because of the uncertainties here this routine will not
+24 ; do TRIGGERS.
+25 ;
+26 ; Xrefs at the multiple level would require a $O through the data
+27 ; global to kill, therefore, sub-file xrefs are not selectable
+28 ; unless they are cross-referenced to the whole file.
+29 ;
START ;
+1 ; Do initialization
DO INIT^AURXREF2
+2 ; Get file to be RE-XREFed
DO GETFILE^AURXREF2
+3 IF AURXREF("QFLG")
DO EOJ
QUIT
+4 ; Build xref table
DO BLDXRT^AURXREF2
+5 IF AURXREF("QFLG")
DO EOJ
QUIT
+6 ; Get confirmation from user
DO CONFIRM^AURXREF2
+7 IF AURXREF("QFLG")
DO EOJ
QUIT
+8 ; Set up xrefs for ^DIK
DO SETUP
+9 ; Kill xrefs
DO KILL
+10 ; For each entry, set xrefs
DO XREF
+11 ; Clean up
DO EOJ
+12 QUIT
+13 ;
SETUP ; SETUP XREFS FOR ^DIK
+1 SET DIK=AURXREF("GBL")
SET X=1
DO DD^DIK
+2 SET AURXREF("DIK FILE")=""
FOR AURXREF("L")=0:0
SET AURXREF("DIK FILE")=$ORDER(^UTILITY("DIK",$JOB,AURXREF("DIK FILE")))
IF AURXREF("DIK FILE")=""
QUIT
DO SETUPB
+3 QUIT
+4 ;
SETUPB ; KILL OFF DIK FILE/SUB-FILES NOT NEEDED
+1 IF '$DATA(^UTILITY("AURXREF",$JOB,AURXREF("DIK FILE")))
KILL ^UTILITY("DIK",$JOB,AURXREF("DIK FILE"))
QUIT
+2 SET AURXREF("DIK FIELD")=""
FOR AURXREF("L")=0:0
SET AURXREF("DIK FIELD")=$ORDER(^UTILITY("DIK",$JOB,AURXREF("DIK FILE"),AURXREF("DIK FIELD")))
IF AURXREF("DIK FIELD")=""
QUIT
DO SETUPC
+3 QUIT
+4 ;
SETUPC ; KILL OFF DIK FIELDS NOT NEEDED
+1 IF '$DATA(^UTILITY("AURXREF",$JOB,AURXREF("DIK FILE"),AURXREF("DIK FIELD")))
KILL ^UTILITY("DIK",$JOB,AURXREF("DIK FILE"),AURXREF("DIK FIELD"))
QUIT
+2 SET AURXREF("DIK XREF")=0
FOR AURXREF("L")=0:0
SET AURXREF("DIK XREF")=$ORDER(^UTILITY("DIK",$JOB,AURXREF("DIK FILE"),AURXREF("DIK FIELD"),AURXREF("DIK XREF")))
IF AURXREF("DIK XREF")=""
QUIT
DO SETUPD
+3 QUIT
+4 ;
SETUPD ; KILL OFF DIK XREFS NOT NEEDED
+1 IF '$DATA(^UTILITY("AURXREF",$JOB,AURXREF("DIK FILE"),AURXREF("DIK FIELD"),AURXREF("DIK XREF")))
KILL ^UTILITY("DIK",$JOB,AURXREF("DIK FILE"),AURXREF("DIK FIELD"),AURXREF("DIK XREF"))
QUIT
+2 QUIT
+3 ;
KILL ; KILL XREFS
+1 SET AURXREF("FILE")=""
FOR AURXREF("L")=0:0
SET AURXREF("FILE")=$ORDER(^UTILITY("AURXREF",$JOB,AURXREF("FILE")))
IF AURXREF("FILE")=""
QUIT
DO KILL2
+2 QUIT
+3 ;
KILL2 ;
+1 SET AURXREF("FIELD")=""
FOR AURXREF("L")=0:0
SET AURXREF("FIELD")=$ORDER(^UTILITY("AURXREF",$JOB,AURXREF("FILE"),AURXREF("FIELD")))
IF AURXREF("FIELD")=""
QUIT
DO KILL3
+2 QUIT
KILL3 ;
+1 SET AURXREF("XREF")=""
FOR AURXREF("L")=0:0
SET AURXREF("XREF")=$ORDER(^UTILITY("AURXREF",$JOB,AURXREF("FILE"),AURXREF("FIELD"),AURXREF("XREF")))
IF AURXREF("XREF")=""
QUIT
DO KILL4
+2 QUIT
+3 ;
KILL4 ;
+1 SET X=^(AURXREF("XREF"))
+2 WRITE !,"Killing ",X
KILL @(AURXREF("GBL")_"X)")
+3 QUIT
+4 ;
XREF ; SET XREFS FOR ALL ENTRIES
+1 DO NOW^%DTC
SET Y=%
XECUTE ^DD("DD")
WRITE !!,"Beginning run at ",$PIECE(Y,"@",2)," <WAIT>"
+2 SET (DA,DCNT)=0
DO CNT^DIK1
+3 QUIT
+4 ;
EOJ ; EOJ HOUSEKEEPING
+1 IF 'AURXREF("QFLG")
DO NOW^%DTC
SET Y=%
XECUTE ^DD("DD")
WRITE !!,"Finished run at ",$PIECE(Y,"@",2)
+2 KILL AURXREF
+3 KILL %,%H,%I,DA,DIC,DIK,X,Y
+4 KILL ^UTILITY("AURXREF",$JOB),^UTILITY("DIK",$JOB)
+5 QUIT