XBRSRCH2	; IHS/ADC/GTH - SEARCH INPUT TRANSFORM 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 INPUT TRANSFORMS that call routines.",!
	S U="^",DIC="^DIC(",DIC(0)="AEMQ"
	D ^DIC
	I Y<0 D EOJ Q
	S XBSINP("FILE")=+Y
	KILL ^UTILITY("XBRSRCH",$J)
	S XBSINP("MASTER")=""
EN	;EP - Search for routines in Input Transforms.
	S XBSINP("LAST FILE")=""
	D SBTRACE
	D:$D(XBSINP("MASTER")) LIST
	D EOJ
	Q
	;
SBTRACE	; CHECK ALL SUB-FILES
	KILL XBSINPFL
	S XBSINP("CNT")=1,XBSINPFL(XBSINP("CNT"))=XBSINP("FILE")
	F XBSINP("L")=0:0 S XBSINP("LCTL")=$O(XBSINPFL("")) Q:XBSINP("LCTL")=""  S XBSINP("FILE")=XBSINPFL(XBSINP("LCTL")) D SBTRACE2 S XBSINP("LCTL")=$O(XBSINPFL("")) D FILE KILL XBSINPFL(XBSINP("LCTL"))
	Q
	;
SBTRACE2	;
	S XBSINP("LCTL")=0
	F XBSINP("L")=0:0 S XBSINP("LCTL")=$O(^DD(XBSINP("FILE"),"SB",XBSINP("LCTL"))) Q:XBSINP("LCTL")=""  S XBSINP("CNT")=XBSINP("CNT")+1,XBSINPFL(XBSINP("CNT"))=XBSINP("LCTL")
	Q
	;
FILE	; CHECK ONE FILE OR SUB-FILE
	S XBSINP("FIELD")=0
	F XBSINP("L")=0:0 S XBSINP("FIELD")=$O(^DD(XBSINP("FILE"),XBSINP("FIELD"))) Q:XBSINP("FIELD")'=+XBSINP("FIELD")  S X=$P(^(XBSINP("FIELD"),0),U,5,99) D:X[U FIELD
	Q
	;
FIELD	; Check Field's Input Transform.
	S XBRSRCH("FOUND")=0,XBSINP("COUNT")=$L(X,U)
	F XBSINP("I")=XBSINP("COUNT"):-1:2 S Y=$P(X,U,XBSINP("I")) D ^XBRSRCH1
	D:XBRSRCH("FOUND") WRITE
	Q
	;
WRITE	;
	I $D(XBRSRCH("NO DETAIL")) W "." Q
	I XBSINP("FILE")'=XBSINP("LAST FILE") S XBSINP("LAST FILE")=XBSINP("FILE") W !
	W !,XBSINP("FILE"),",",XBSINP("FIELD"),?20,$E(X,1,59)
	F XBSINP("L")=0:0 S X=$E(X,60,999) Q:X=""  W !?20,$E(X,1,59)
	Q
	;
LIST	; List Routine Names.
	Q:'$D(^UTILITY("XBRSRCH",$J))
	W !!,"Sorted list of routines found:",!
	S X=""
	F XBSINP("L")=0:0 S X=$O(^UTILITY("XBRSRCH",$J,X)) Q:X=""  W !,"^",X
	KILL ^UTILITY("XBRSRCH",$J)
	W !
	Q
	;
EOJ	;
	KILL DIC,X,X0,X1,X2,Y,YY
	KILL:$D(XBSINP("MASTER")) XBRSRCH
	KILL XBSINP,XBSINPFL
	Q
	;
