DDBR ;SFISC/DCL-VA FILEMAN BROWSER ;4MAY2011
;;22.0;VA FileMan;**165**;Mar 30, 1999;Build 34
;Per VHA Directive 2004-038, this routine should not be modified.
EN N DDBC,DDBFLG,DDBL,DDBPMSG,DDBSA,DDBX,IOTM,IOBM
I '$$TEST^DDBRT W $C(7),!!,"This terminal does not support scroll region or reverse index",!! Q
D LIST^DDBR3(.DDBX)
I DDBX'>0 W:DDBX=0 $C(7),!!,"No Text",!! Q
S DDBSA=DDBX(6)
S DDBFLG=DDBX(4)
S DDBPMSG=DDBX(5)
D CONTNU
D KTMP^DDBRU
Q
WP(DDBFN,DDBRN,DDBFLD,DDBFLG,DDBPMSG,DDBL,DDBC,IOTM,IOBM) N DDBSA
S DDBSA=$$GET^DIQG($G(DDBFN),$G(DDBRN),$G(DDBFLD),"B")
I $G(DIERR) D CLEAN Q
S DDBSA=$P(DDBSA,"$CREF$",2)
I DDBSA']"" D ERR("FILE, RECORD and/or FIELD") Q
I '$D(@DDBSA) D ERR("SOURCE ARRAY") Q
I $G(DDBFLG)["A" D
.N DDBSAN
.S DDBSAN=$$NROOT^DDBRAP($NA(@DDBSA))
.I '$D(@DDBSAN) D WP^DDBRAP($NA(@DDBSA))
.Q:$G(DDBPMSG)]""
.I $D(@DDBSAN@("TITLE")) S DDBPMSG=@DDBSAN@("TITLE") Q
.Q
S DDBPMSG=$S($G(DDBPMSG)]"":DDBPMSG,1:"VA FileMan Browser (wp) DOCUMENT 1")
D CONTNU
D:$G(DDBFLG)'["P" KTMP^DDBRU
Q
BROWSE(DDBSA,DDBFLG,DDBPMSG,DDBL,DDBC,IOTM,IOBM) N DDBRLIST
CONTNU I $G(U)'="^" N U S U="^"
I $G(DDBFLG)["A" D
.N DDBSAN
.S DDBSAN=$$NROOT^DDBRAP($NA(@DDBSA))
.I '$D(@DDBSAN) D WP^DDBRAP($NA(@DDBSA))
.Q:$G(DDBPMSG)]""
.I $D(@DDBSAN@("TITLE")) S DDBPMSG=@DDBSAN@("TITLE") Q
.Q
S DDBPMSG=$S($G(DDBPMSG)]"":DDBPMSG,1:"VA FileMan Browser DOCUMENT 1")
N %,D,DX,IOP,XY,X,Y
D:$G(DDBFLG)'["H" INIT I $G(DIERR) D CLEAN Q
I $G(DDBSA)']"" D ERR("SOURCE ARRAY") Q
I '$D(@DDBSA) D ERR("SOURCE ARRAY") Q
I $G(DDBFLG)'["N",DDBSA'="^TMP(""DDB"",$J)" D
.I $NA(@DDBSA)=$NA(^TMP("DDB",$J)) S DDBSA="^TMP(""DDB"",$J)" Q
.K ^TMP("DDB",$J)
.D XY^%RCR($$OREF(DDBSA),"^TMP(""DDB"",$J,")
.;M ^TMP("DDB",$J)=@DDBSA
.S DDBSA="^TMP(""DDB"",$J)"
.Q
N DDBRE,DDBRPE,DDBPSA,DDBTO,DDBDM,DDBFNO,I,DDBFLGS,DDBRHT,DDBRHTF
N DDBHDR,DDBHDRC,DDBFTR,DDBSP,DDBSF,DDBST,DDBTL,DDBTPG,DDBZN
I '$G(DDBRLIST) N DDBSRL,DDBSX,DDBSY,DDBRSA
S DDBFTR=$E("Col> |<PF1>H=Help <PF1>E=Exit| Line> Screen>"_$J("",IOM),1,IOM)
I '$G(DDBRLIST) S IOBM=$S($G(IOBM)>0:IOBM,1:$G(IOSL,24))-1,IOTM=$S($G(IOTM)>0:IOTM,1:1)+1
S DDBRSA=0
D TB^DDBRS(.IOTM,.IOBM,.DDBRSA)
S DDBSX="0;4;40;65"
S DDBSY=DDBRSA(0,"DDBSY")
I IOBM>(IOSL-1) D ERR("BOTTOM MARGIN") Q
I IOTM<2 D ERR("TOP MARGIN") Q
I IOBM'>IOTM D ERR("TOP & BOTTOM MARGINS") Q
S DDBSRL=DDBRSA(0,"DDBSRL")
I DDBSRL'>4,$G(DDBFLG)'["H" D ERR("SCROLL REGION (TOO SMALL)") Q
I DDBRSA(1,"DDBSRL")'>4 K DDBRSA(1),DDBRSA(2)
S DDBHDR=$$CTXT(DDBPMSG,$J("",IOM+1),IOM),DDBHDRC=0
S DDBTL=$P($G(@DDBSA@(0)),"^",3) S:DDBTL'>0 DDBTL=$O(@DDBSA@(" "),-1)
I DDBTL'>0 D I DDBTL'>0 D BLD^DIALOG(1700,"*NO TEXT*"_DDBSA) D CLEAN Q
.N I S I=0 F S I=$O(@DDBSA@(I)) Q:I'>0 S DDBTL=I
.Q
S DDBZN=$D(@DDBSA@(DDBTL,0))#2,DDBTPG=DDBTL\DDBSRL+(DDBTL#DDBSRL'<1),DDBSF=1,DDBST=IOM
S DDBDM=DDBSA="^TMP(""DDB"",$J)"
I $G(DDBC)=+$G(DDBC) D ERR("TAB (Closed Array Root)") Q
S:$G(DDBC)="" DDBC="^TMP(""DDBC"",$J)"
I '$D(@DDBC) F I=1,22:22:176 S @DDBC@(I)=""
I $D(@DDBC@(1))'>9 N DDBC0,DDBC1 S @DDBC@(1)="",DDBC1=1,DDBC0=DDBC
S DDBPSA=0,DDBFLG=$G(DDBFLG)
S DDBFLGS=DDBFLG["S",DDBRHTF=DDBFLG["A"
I DDBRHTF S $E(DDBFTR,1,9)="HYPER-TXT"
G EN^DDBRGE
DOCLIST(DDBDSA,DDBFLG,IOTM,IOBM) S IOP="HOME" D ^%ZIS
N DDBPMSG,DDBL,DDBC,DDBSA,DDBSRL,DDBSX,DDBSY,DDBRSA,DDBRLIST
S IOBM=$S($G(IOBM)>0:IOBM,1:$G(IOSL,24))-1,IOTM=$S($G(IOTM)>0:IOTM,1:1)+1
S DDBSX="0;4;40;65"
S DDBSY=(IOTM-2)_";"_(IOTM-1)_";"_(IOBM-1)_";"_(IOBM) ;hdr,txttop,txtbot,ftr
I IOBM>(IOSL-1) D ERR("BOTTOM MARGIN") Q
I IOTM<2 D ERR("TOP MARGIN") Q
I IOBM'>IOTM D ERR("TOP & BOTTOM MARGINS") Q
S DDBSRL=(IOBM-IOTM)+1 ;scroll region lines
I '$D(@DDBDSA) D ERR("DOCUMENT ARRAY INVALID") Q
S DDBFLG=$TR($G(DDBFLG),"P")_"N"
S DDBPMSG=$O(@DDBDSA@("")) S:DDBPMSG]"" DDBSA=@DDBDSA@(DDBPMSG)
I DDBPMSG']""!(DDBSA']"") D ERR("DOCUMENT ARRAY INVALID") Q
D I $G(DIERR) K ^TMP("DDBLST",$J) D CLEAN Q
.N DOC,DOCSA
.S DOC=""
.K ^TMP("DDBLST",$J)
.F S DOC=$O(@DDBDSA@(DOC)) Q:DOC="" D
..S DOCSA=@DDBDSA@(DOC)
..D LOADCL^DDBR4(DOCSA,"",DOC)
..Q
.Q
Q:$G(DDBENDR)
S DDBRLIST=1
G CONTNU
RTN G DR^DDBRU
ROOT G EN^DDBRU2
CTXT(X,T,W) Q:X="" $G(T)
N HW
S W=$G(W,79),HW=W\2
S $E(T,HW-($L(X)\2),HW-($L(X)\2)+$L(X))=X Q $E(T,1,W)
OREF(X) N X1,X2 S X1=$P(X,"(")_"(",X2=$$OR2($P(X,"(",2)) Q:X2="" X1 Q X1_X2_","
OR2(%) Q:%=")"!(%=",") "" Q:$L(%)=1 % S:"),"[$E(%,$L(%)) %=$E(%,1,$L(%)-1) Q %
INIT I '$D(DIFM) N DIFM S DIFM=1 D INIZE^DIEFU
D INIT^DDGLIB0()
I $G(DIERR) Q
I '$D(IOSTBM)!('$D(IORI)) S X="IOSTBM;IORI" D ENDR^%ZISS
D:$G(IOSTBM)="" TRMERR^DDGLIB0("Set top and bottom margins")
D:$G(IORI)="" TRMERR^DDGLIB0("Reverse index")
Q
ERR(DDBERR) N P S P(1)=DDBERR
I $G(U)="^" N U S U="^"
D BLD^DIALOG(202,.P),OUT^DDBRU:$D(DDGLDEL)
CLEAN D:'$D(DDS) KILL^DDGLIB0($G(DDBFLG))
Q
DDBR ;SFISC/DCL-VA FILEMAN BROWSER ;4MAY2011
+1 ;;22.0;VA FileMan;**165**;Mar 30, 1999;Build 34
+2 ;Per VHA Directive 2004-038, this routine should not be modified.
EN NEW DDBC,DDBFLG,DDBL,DDBPMSG,DDBSA,DDBX,IOTM,IOBM
+1 IF '$$TEST^DDBRT
WRITE $CHAR(7),!!,"This terminal does not support scroll region or reverse index",!!
QUIT
+2 DO LIST^DDBR3(.DDBX)
+3 IF DDBX'>0
IF DDBX=0
WRITE $CHAR(7),!!,"No Text",!!
QUIT
+4 SET DDBSA=DDBX(6)
+5 SET DDBFLG=DDBX(4)
+6 SET DDBPMSG=DDBX(5)
+7 DO CONTNU
+8 DO KTMP^DDBRU
+9 QUIT
WP(DDBFN,DDBRN,DDBFLD,DDBFLG,DDBPMSG,DDBL,DDBC,IOTM,IOBM) NEW DDBSA
+1 SET DDBSA=$$GET^DIQG($GET(DDBFN),$GET(DDBRN),$GET(DDBFLD),"B")
+2 IF $GET(DIERR)
DO CLEAN
QUIT
+3 SET DDBSA=$PIECE(DDBSA,"$CREF$",2)
+4 IF DDBSA']""
DO ERR("FILE, RECORD and/or FIELD")
QUIT
+5 IF '$DATA(@DDBSA)
DO ERR("SOURCE ARRAY")
QUIT
+6 IF $GET(DDBFLG)["A"
Begin DoDot:1
+7 NEW DDBSAN
+8 SET DDBSAN=$$NROOT^DDBRAP($NAME(@DDBSA))
+9 IF '$DATA(@DDBSAN)
DO WP^DDBRAP($NAME(@DDBSA))
+10 IF $GET(DDBPMSG)]""
QUIT
+11 IF $DATA(@DDBSAN@("TITLE"))
SET DDBPMSG=@DDBSAN@("TITLE")
QUIT
+12 QUIT
End DoDot:1
+13 SET DDBPMSG=$SELECT($GET(DDBPMSG)]"":DDBPMSG,1:"VA FileMan Browser (wp) DOCUMENT 1")
+14 DO CONTNU
+15 IF $GET(DDBFLG)'["P"
DO KTMP^DDBRU
+16 QUIT
BROWSE(DDBSA,DDBFLG,DDBPMSG,DDBL,DDBC,IOTM,IOBM) NEW DDBRLIST
CONTNU IF $GET(U)'="^"
NEW U
SET U="^"
+1 IF $GET(DDBFLG)["A"
Begin DoDot:1
+2 NEW DDBSAN
+3 SET DDBSAN=$$NROOT^DDBRAP($NAME(@DDBSA))
+4 IF '$DATA(@DDBSAN)
DO WP^DDBRAP($NAME(@DDBSA))
+5 IF $GET(DDBPMSG)]""
QUIT
+6 IF $DATA(@DDBSAN@("TITLE"))
SET DDBPMSG=@DDBSAN@("TITLE")
QUIT
+7 QUIT
End DoDot:1
+8 SET DDBPMSG=$SELECT($GET(DDBPMSG)]"":DDBPMSG,1:"VA FileMan Browser DOCUMENT 1")
+9 NEW %,D,DX,IOP,XY,X,Y
+10 IF $GET(DDBFLG)'["H"
DO INIT
IF $GET(DIERR)
DO CLEAN
QUIT
+11 IF $GET(DDBSA)']""
DO ERR("SOURCE ARRAY")
QUIT
+12 IF '$DATA(@DDBSA)
DO ERR("SOURCE ARRAY")
QUIT
+13 IF $GET(DDBFLG)'["N"
IF DDBSA'="^TMP(""DDB"",$J)"
Begin DoDot:1
+14 IF $NAME(@DDBSA)=$NAME(^TMP("DDB",$JOB))
SET DDBSA="^TMP(""DDB"",$J)"
QUIT
+15 KILL ^TMP("DDB",$JOB)
+16 DO XY^%RCR($$OREF(DDBSA),"^TMP(""DDB"",$J,")
+17 ;M ^TMP("DDB",$J)=@DDBSA
+18 SET DDBSA="^TMP(""DDB"",$J)"
+19 QUIT
End DoDot:1
+20 NEW DDBRE,DDBRPE,DDBPSA,DDBTO,DDBDM,DDBFNO,I,DDBFLGS,DDBRHT,DDBRHTF
+21 NEW DDBHDR,DDBHDRC,DDBFTR,DDBSP,DDBSF,DDBST,DDBTL,DDBTPG,DDBZN
+22 IF '$GET(DDBRLIST)
NEW DDBSRL,DDBSX,DDBSY,DDBRSA
+23 SET DDBFTR=$EXTRACT("Col> |<PF1>H=Help <PF1>E=Exit| Line> Screen>"_$JUSTIFY("",IOM),1,IOM)
+24 IF '$GET(DDBRLIST)
SET IOBM=$SELECT($GET(IOBM)>0:IOBM,1:$GET(IOSL,24))-1
SET IOTM=$SELECT($GET(IOTM)>0:IOTM,1:1)+1
+25 SET DDBRSA=0
+26 DO TB^DDBRS(.IOTM,.IOBM,.DDBRSA)
+27 SET DDBSX="0;4;40;65"
+28 SET DDBSY=DDBRSA(0,"DDBSY")
+29 IF IOBM>(IOSL-1)
DO ERR("BOTTOM MARGIN")
QUIT
+30 IF IOTM<2
DO ERR("TOP MARGIN")
QUIT
+31 IF IOBM'>IOTM
DO ERR("TOP & BOTTOM MARGINS")
QUIT
+32 SET DDBSRL=DDBRSA(0,"DDBSRL")
+33 IF DDBSRL'>4
IF $GET(DDBFLG)'["H"
DO ERR("SCROLL REGION (TOO SMALL)")
QUIT
+34 IF DDBRSA(1,"DDBSRL")'>4
KILL DDBRSA(1),DDBRSA(2)
+35 SET DDBHDR=$$CTXT(DDBPMSG,$JUSTIFY("",IOM+1),IOM)
SET DDBHDRC=0
+36 SET DDBTL=$PIECE($GET(@DDBSA@(0)),"^",3)
IF DDBTL'>0
SET DDBTL=$ORDER(@DDBSA@(" "),-1)
+37 IF DDBTL'>0
Begin DoDot:1
+38 NEW I
SET I=0
FOR
SET I=$ORDER(@DDBSA@(I))
IF I'>0
QUIT
SET DDBTL=I
+39 QUIT
End DoDot:1
IF DDBTL'>0
DO BLD^DIALOG(1700,"*NO TEXT*"_DDBSA)
DO CLEAN
QUIT
+40 SET DDBZN=$DATA(@DDBSA@(DDBTL,0))#2
SET DDBTPG=DDBTL\DDBSRL+(DDBTL#DDBSRL'<1)
SET DDBSF=1
SET DDBST=IOM
+41 SET DDBDM=DDBSA="^TMP(""DDB"",$J)"
+42 IF $GET(DDBC)=+$GET(DDBC)
DO ERR("TAB (Closed Array Root)")
QUIT
+43 IF $GET(DDBC)=""
SET DDBC="^TMP(""DDBC"",$J)"
+44 IF '$DATA(@DDBC)
FOR I=1,22:22:176
SET @DDBC@(I)=""
+45 IF $DATA(@DDBC@(1))'>9
NEW DDBC0,DDBC1
SET @DDBC@(1)=""
SET DDBC1=1
SET DDBC0=DDBC
+46 SET DDBPSA=0
SET DDBFLG=$GET(DDBFLG)
+47 SET DDBFLGS=DDBFLG["S"
SET DDBRHTF=DDBFLG["A"
+48 IF DDBRHTF
SET $EXTRACT(DDBFTR,1,9)="HYPER-TXT"
+49 GOTO EN^DDBRGE
DOCLIST(DDBDSA,DDBFLG,IOTM,IOBM) SET IOP="HOME"
DO ^%ZIS
+1 NEW DDBPMSG,DDBL,DDBC,DDBSA,DDBSRL,DDBSX,DDBSY,DDBRSA,DDBRLIST
+2 SET IOBM=$SELECT($GET(IOBM)>0:IOBM,1:$GET(IOSL,24))-1
SET IOTM=$SELECT($GET(IOTM)>0:IOTM,1:1)+1
+3 SET DDBSX="0;4;40;65"
+4 ;hdr,txttop,txtbot,ftr
SET DDBSY=(IOTM-2)_";"_(IOTM-1)_";"_(IOBM-1)_";"_(IOBM)
+5 IF IOBM>(IOSL-1)
DO ERR("BOTTOM MARGIN")
QUIT
+6 IF IOTM<2
DO ERR("TOP MARGIN")
QUIT
+7 IF IOBM'>IOTM
DO ERR("TOP & BOTTOM MARGINS")
QUIT
+8 ;scroll region lines
SET DDBSRL=(IOBM-IOTM)+1
+9 IF '$DATA(@DDBDSA)
DO ERR("DOCUMENT ARRAY INVALID")
QUIT
+10 SET DDBFLG=$TRANSLATE($GET(DDBFLG),"P")_"N"
+11 SET DDBPMSG=$ORDER(@DDBDSA@(""))
IF DDBPMSG]""
SET DDBSA=@DDBDSA@(DDBPMSG)
+12 IF DDBPMSG']""!(DDBSA']"")
DO ERR("DOCUMENT ARRAY INVALID")
QUIT
+13 Begin DoDot:1
+14 NEW DOC,DOCSA
+15 SET DOC=""
+16 KILL ^TMP("DDBLST",$JOB)
+17 FOR
SET DOC=$ORDER(@DDBDSA@(DOC))
IF DOC=""
QUIT
Begin DoDot:2
+18 SET DOCSA=@DDBDSA@(DOC)
+19 DO LOADCL^DDBR4(DOCSA,"",DOC)
+20 QUIT
End DoDot:2
+21 QUIT
End DoDot:1
IF $GET(DIERR)
KILL ^TMP("DDBLST",$JOB)
DO CLEAN
QUIT
+22 IF $GET(DDBENDR)
QUIT
+23 SET DDBRLIST=1
+24 GOTO CONTNU
RTN GOTO DR^DDBRU
ROOT GOTO EN^DDBRU2
CTXT(X,T,W) IF X=""
QUIT $GET(T)
+1 NEW HW
+2 SET W=$GET(W,79)
SET HW=W\2
+3 SET $EXTRACT(T,HW-($LENGTH(X)\2),HW-($LENGTH(X)\2)+$LENGTH(X))=X
QUIT $EXTRACT(T,1,W)
OREF(X) NEW X1,X2
SET X1=$PIECE(X,"(")_"("
SET X2=$$OR2($PIECE(X,"(",2))
IF X2=""
QUIT X1
QUIT X1_X2_","
OR2(%) IF %=")"!(%=",")
QUIT ""
IF $LENGTH(%)=1
QUIT %
IF "),"[$EXTRACT(%,$LENGTH(%))
SET %=$EXTRACT(%,1,$LENGTH(%)-1)
QUIT %
INIT IF '$DATA(DIFM)
NEW DIFM
SET DIFM=1
DO INIZE^DIEFU
+1 DO INIT^DDGLIB0()
+2 IF $GET(DIERR)
QUIT
+3 IF '$DATA(IOSTBM)!('$DATA(IORI))
SET X="IOSTBM;IORI"
DO ENDR^%ZISS
+4 IF $GET(IOSTBM)=""
DO TRMERR^DDGLIB0("Set top and bottom margins")
+5 IF $GET(IORI)=""
DO TRMERR^DDGLIB0("Reverse index")
+6 QUIT
ERR(DDBERR) NEW P
SET P(1)=DDBERR
+1 IF $GET(U)="^"
NEW U
SET U="^"
+2 DO BLD^DIALOG(202,.P)
IF $DATA(DDGLDEL)
DO OUT^DDBRU
CLEAN IF '$DATA(DDS)
DO KILL^DDGLIB0($GET(DDBFLG))
+1 QUIT