XBRSRCH5	; IHS/ADC/GTH - SEARCH MISCELLANEOUS FOR ROUTINES ; [ 02/07/97   3:02 PM ]
	;;4.0;XB;;Jul 20, 2009;Build 2
	;
	; Part of XBRSRCH
	;
START	;
	W !!,"This routine searches a file for MISCELLANEOUS ^DD ENTRIES that call routines.",!
	S U="^",DIC="^DIC(",DIC(0)="AEMQ"
	D ^DIC
	I Y<0 D EOJ Q
	S XBSM("FILE")=+Y
	KILL ^UTILITY("XBRSRCH",$J)
	S XBSM("MASTER")=""
EN	;EP - ENTRY POINT FOR CALLING ROUTINES
	S XBSM("LAST FILE")=""
	D FILE
	D:$D(XBSM("MASTER")) LIST
	D EOJ
	Q
	;
FILE	; CHECK ONE FILE
	I $D(^DD(XBSM("FILE"),0,"ACT")) S X=^("ACT"),XBSM("GR")=$$MSMZR^ZIBNSSV D FILE2
	I $D(^DD(XBSM("FILE"),0,"SCR")) S X=^("SCR"),XBSM("GR")=$$MSMZR^ZIBNSSV D FILE2
	I $D(^DD(XBSM("FILE"),0,"ID")) S XBSM("FIELD")="" F XBSM("L")=0:0 S XBSM("FIELD")=$O(^DD(XBSM("FILE"),0,"ID",XBSM("FIELD"))) Q:XBSM("FIELD")=""  S X=^(XBSM("FIELD")),XBSM("GR")=$$MSMZR^ZIBNSSV D FILE2
	I $D(^DD(XBSM("FILE"),.01,7.5)) S X=^(7.5),XBSM("GR")=$$MSMZR^ZIBNSSV D FILE2
	I $D(^DD(XBSM("FILE"),.01,"DEL")) S XBSM("SUB")="DEL" D FIELD
	I $D(^DD(XBSM("FILE"),.01,"LAYGO")) S XBSM("SUB")="LAYGO" D FIELD
	Q
	;
FIELD	; CHECK ONE FIELD
	S XBSM("FIELD")=""
	F XBSM("L")=0:0 S XBSM("FIELD")=$O(^DD(XBSM("FILE"),.01,XBSM("SUB"),XBSM("FIELD"))) Q:XBSM("FIELD")=""  D FIELD2
	Q
	;
FIELD2	;
	S XBSM("NODE")=""
	F XBSM("L")=0:0 S XBSM("NODE")=$O(^DD(XBSM("FILE"),.01,XBSM("SUB"),XBSM("FIELD"),XBSM("NODE"))) Q:XBSM("NODE")=""  S X=^(XBSM("NODE")),XBSM("GR")=$$MSMZR^ZIBNSSV D FILE2
	Q
	;
FILE2	;
	Q:X'[U
	S XBRSRCH("FOUND")=0,XBSM("COUNT")=$L(X,U)
	F XBSM("I")=XBSM("COUNT"):-1:2 S Y=$P(X,U,XBSM("I")) D ^XBRSRCH1
	D:XBRSRCH("FOUND") WRITE
	Q
	;
WRITE	;
	I $D(XBRSRCH("NO DETAIL")) W "." Q
	I XBSM("FILE")'=XBSM("LAST FILE") S XBSM("LAST FILE")=XBSM("FILE") W !
	W !,XBSM("GR"),?30,$E(X,1,49)
	F XBSM("L")=0:0 S X=$E(X,50,999) Q:X=""  W !?30,$E(X,1,49)
	Q
	;
LIST	; LIST ROUTINE NAMES
	Q:'$D(^UTILITY("XBRSRCH",$J))
	W !!,"Sorted list of routines found:",!
	S X=""
	F XBSM("L")=0:0 S X=$O(^UTILITY("XBRSRCH",$J,X)) Q:X=""  W !,"^",X
	KILL ^UTILITY("XBRSRCH",$J)
	W !
	Q
	;
EOJ	;
	KILL DIC
	KILL X,X0,X1,X2,Y,YY
	KILL:$D(XBSM("MASTER")) XBRSRCH
	KILL XBSM,XBSMFL
	Q
	;
