source: FOIAVistA/trunk/r/KERNEL-XU-A4A7-USC-XG-XLF-XNOA-XPD-XQ-XVIR-ZI-ZOSF-ZOSV-ZT-ZU-%Z-XIP--XQAB--XUC--XUR--ZIN--ZTED/XQ3.m@ 1742

Last change on this file since 1742 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 4.5 KB
Line 
1XQ3 ;LL/THM,SF/GJL,SEA/JLI - CLEANUP DANGLING POINTERS IN OPTION OR HELP FRAME FILES ;04/30/08 17:06
2 ;;8.0;KERNEL;**80,501**;Jul 10, 1995;Build 1
3 Q
4ENASK ;Ask to fix up dirty OPTION/HELP FRAME File
5 N IX,XUT,J,K,XQFL,X
6 I '$D(%) W !,$C(7),"ENTRY MUST BE WITH THE VARIABLE '%' SET TO INDICATE DESIRED FILE.",$C(7),! Q
7 S XQFL=$S(%=1:"OPTION",%=2:"PROTOCOL",1:"HELP FRAME")
8 W !,"Do you want to remove any 'Dangling Pointers' from your ",XQFL," File? Y// " R X:$S($D(DTIME):DTIME,1:300) I '$T Q
9 W ! I X="" S X="Y"
10 I X["?" G SYNTAX
11 I X["^" S X="^" Q
12STRIP I X'="",X'?1A.E S X=$E(X,2,256) G STRIP
13 S X=$E(X,1) I X="" G SYNTAX
14 I "Nn"[X S X="N" Q
15 I "Yy"[X W !,"PLEASE WAIT while I check this out . . . " G REMOVE
16SYNTAX W ! I X'["?" W ?11,"I'm sorry, but I don't understand your answer. Please"
17 W !,"Enter: YES (or press the RETURN key) if you want me to remove from"
18 W !,?11,"your ",XQFL," File any pointers left over from incompletely"
19 W !,?11,"deleted ",XQFL,". If such pointers do exist and are not"
20 W !,?11,"removed, the ",XQFL," File (i.e. the menus) could become"
21 W !,?11,"messed up by an INIT."
22 W !!,"Enter: NO or ^ to continue on without effecting the ",XQFL," File."
23 W ! G ENASK
24REMOVE D:%=1 OPFIX D:%=2 PFIX D:'% HFFIX W !,"Your ",XQFL," File is OK " I 'XUT W "(no bad pointers)."
25 E W "now (",XUT," pointer" W:XUT>1 "s" W " fixed)."
26 W ! S X="Y"
27 Q
28OPFIX ;Kill any dangling pointers in the OPTION File (#19)
29 N %,IX,J,XQ3
30 S (IX,XUT)=0 ;XUT=Total Deletions
31 F S IX=$O(^DIC(19,IX)) Q:'IX W:'(IX#100) ". " S (XQ3,J)=0 D L2 ;Loop through Options
32 D NPF
33 Q
34L2 ;One Option
35 I '$D(^DIC(19,IX,10,0)) Q ;Not a Menu
36 K ^DIC(19,IX,10,"B") ;Rebuild "B" X-ref
37 F S J=$O(^DIC(19,IX,10,J)) Q:'J D ITEM ;Loop through menu items
38 S (K,J)=0 F S J=$O(^DIC(19,IX,10,J)) Q:J'>0 S K=J ;K=Last item
39 S J=^DIC(19,IX,10,0),^(0)=$P(J,"^",1,2)_"^"_K_"^"_XQ3 ;fix counters
40 Q
41 ;
42ITEM ;One Menu item
43 N DA,DIK
44 S K=+^DIC(19,IX,10,J,0)
45 I $D(^DIC(19,K,0)) S XQ3=XQ3+1,^DIC(19,IX,10,"B",K,J)="" Q ;Y=No. of items
46 W !,"Option ",$P(^DIC(19,IX,0),U,1)," points to missing option ",K
47 ;S XUT=XUT+1 K ^DIC(19,IX,10,J) ;Kill invalid menu item
48 S XUT=XUT+1,DIK="^DIC(19,DA(1),10,",DA=J,DA(1)=IX D ^DIK ;Trigger Menu-rebuild
49 Q
50 ;
51NPF ;Fix the New Person File Option Pointers
52 N IX,I2,J,P,DIK,DIE,DR,DA,XUT
53 S (XUT,IX)=0
54 F S IX=$O(^VA(200,IX)) Q:'IX D
55 . S P=+$G(^VA(200,IX,201))
56 . I P,'$D(^DIC(19,P,0)) D
57 . . W !,"User: ",$P(^VA(200,IX,0),U),", Primary Menu points to missing option ",P
58 . . S XUT=XUT+1,DIE="^VA(200,",DA=IX,DR="201///@" D ^DIE
59 . . Q
60 . S I2=0
61 . F S I2=$O(^VA(200,IX,203,I2)) Q:'I2 D
62 . . S P=+$G(^VA(200,IX,203,I2,0))
63 . . I P,'$D(^DIC(19,P,0)) D
64 . . . W !,"User: ",$P(^VA(200,IX,0),U),", Secondary Menu points to missing option ",P
65 . . . S XUT=XUT+1,DIK="^VA(200,DA(1),203,",DA=I2,DA(1)=IX D ^DIK
66 . . . Q
67 . . Q
68 . Q
69 I XUT W !,"Menu pointers fixed."
70 Q
71HFFIX ; Fix dangling pointers on help frame file
72 N %
73 S (XUT,IX)=0 F S IX=$O(^DIC(9.2,IX)) Q:IX'>0 I $D(^(IX,2)) D HF1,HF2,HF3
74 Q
75HF1 S (Y,J)=0 F S J=$O(^DIC(9.2,IX,2,J)) Q:J'>0 I $D(^(J,0)) S K=$P(^(0),U,2),Y=Y+1 I $L(K),'$D(^DIC(9.2,K)) S Y=Y-1,XUT=XUT+1 K ^DIC(9.2,IX,2,J,0)
76 Q
77HF2 S (K,J)=0 F S J=$O(^DIC(9.2,IX,2,J)) Q:J'>0 S K=J
78 S J=^DIC(9.2,IX,2,0),^(0)=$P(J,U,1,2)_U_K_U_Y
79 Q
80HF3 S K=":" F S K=$O(^DIC(9.2,IX,2,K)) Q:K="" S J=-1 F S J=$O(^DIC(9.2,IX,2,K,J)) Q:J="" D HF4
81 Q
82HF4 S JJ=0 F S JJ=$O(^DIC(9.2,IX,2,K,J,JJ)) Q:JJ'>0 I '$D(^DIC(9.2,IX,2,JJ,0)) K ^DIC(9.2,IX,2,K,J,JJ)
83 Q
84PFIX ;Kill any dangling pointers in the PROTOCOL File (#101)
85 N %
86 S (IX,XUT)=0 ;XUT=Total Deletions
87P1 S IX=$O(^ORD(101,IX)) I IX>0 S (Y,J)=0 G P2 ;Loop through protocols
88 Q
89P2 S J=$O(^ORD(101,IX,10,J)) I J>0 G PITEM ;Loop through items
90 I '$D(^ORD(101,IX,10,0)) G P1
91 S (K,J)=0 F L=1:1 S J=$O(^ORD(101,IX,10,J)) Q:J'>0 S K=J ;K=Last item
92 S J=^ORD(101,IX,10,0),^(0)=$P(J,"^",1,2)_"^"_K_"^"_Y ;fix counters
93 G PXREFS
94PITEM S K=+^ORD(101,IX,10,J,0) I $D(^ORD(101,K,0)) S Y=Y+1 G P2 ;Y=No. of items
95 W !,"Protocol ",$P(^ORD(101,IX,0),U,1)," points to missing protocol ",K
96 ;S XUT=XUT+1 K ^ORD(101,IX,10,J) ;Kill invalid menu item
97 S XUT=XUT+1,DIK="^ORD(101,IX,10,",DA=J,DA(1)=IX D ^DIK ;Delete invalid menu item
98 G P2
99PXREFS S K=":"
100P3 S K=$O(^ORD(101,IX,10,K)) I K="" G P1 ;Loop through cross references
101 S L=-1
102P4 S L=$O(^ORD(101,IX,10,K,L)) I L="" G P3
103 S J=0
104P5 S J=$O(^ORD(101,IX,10,K,L,J)) I J'>0 G P4
105 I '$D(^ORD(101,IX,10,J,0)) G PKILLXR ;kill xref to invalid item
106P6 S M=^ORD(101,IX,10,J,0) I (M=L)!(M[L_"^") G P5
107PKILLXR K ^ORD(101,IX,10,K,L,J) I $O(^ORD(101,IX,10,K,L,-1))="" K ^ORD(101,IX,10,K,L)
108 G P5
Note: See TracBrowser for help on using the repository browser.