DIR0 ;SFISC/MKO-FIELD EDITOR ;09DEC2015
;;22.2;VA FileMan;;Jan 05, 2016;Build 42
;;Per VA Directive 6402, this routine should not be modified.
;;Submitted to OSEHRA 5 January 2015 by the VISTA Expertise Network.
;;Based on Medsphere Systems Corporation's MSC FileMan 1051.
;;Licensed under the terms of the Apache License, Version 2.0.
;
SM ;
N DIR0A,DIR0C,DIR0CH,DIR0CHG,DIR0D,DIR0F,DIR0L,DIR0M
N DIR0P,DIR0QT,DIR0QU,DIR0R,DIR0RJ,DIR0S,DIR0SP,DIR0ST,DIR0SV,DX,DY
S DIR0P="" D:$D(DIR0("IN"))[0 GETKEY^DIR0K
S:$P(DIR0,U,6) DIR0RJ=1
;
I $G(DDSH) K DDSH D BOT^DDSCOM ;BEFORE THE READ, WRITE THE COMMAND LINE!
S (DIR0A,DIR0D)=$G(DIR("B"))
S DIR0R=$P(DIR0,U),DIR0S=$P(DIR0,U,2),DIR0L=$P(DIR0,U,3),DIR0M=245
;
W $P(DDGLVID,DDGLDEL,10)
S DY=$P(DIR0,U,4),DX=$P(DIR0,U,5)
I $D(DIR("A"))=11 D
. N DIX
. S DIX="" F S DIX=$O(DIR("A",DIX)) Q:DIX="" D
.. X IOXY W DIR("A",DIX)
.. S DY=DY+1
;
I $D(DIR("A"))#2 D
. X IOXY W DIR("A")
. I DDO,DY=IOSL-1 W $P(DDGLCLR,DDGLDEL)
;
D INIT,^DIR01 ;Go do the READ
;
A I $D(DTOUT) W $C(7) S DIR0A=DIR0D
I DIR0A="@",DIR0D'="@" S DIR0A=""
S:DIR0CH="QT" DIR0A=DIR0D
S X=DIR0A
S:X?1"^".E!(X?1"?".E) DIR0A=DIR0D
S DIR0N=X=DIR0D S:DIR0A'=DIR0D DIR0("L")=DIR0A
;
D END,PAINT
X DDGLZOSF("EON"),DDGLZOSF("TRMOFF")
Q
;
;
;
EN(DIR0R,DIR0S,DIR0L,DIR0NL,DIR0A,DIR0M,DIR0C,DIR0MAP,DIR0FLG,X,Y) ;
;$Y $X length default
;Field editor
N DIR0CH,DIR0CHG,DIR0D,DIR0F,DIR0KD,DIR0P,DIR0QT,DIR0QU
N DIR0RJ,DIR0SP,DIR0ST,DIR0SV,DIR0TO,DX,DY
;
D INIT^DDGLIB0() ;BEFORE, $Y=4 AFTER $Y=0
;
I $D(DIR0MAP)<2 D
. S DIR0P="D"
. D:$D(DIR0("DIN"))[0 GETKEY^DIR0K
E D
. S DIR0P="C"
. I $O(DIR0MAP(""))!($D(DIR0MAP("IN"))[0) D
.. D GETKEY^DIR0K
.. K DIR0MAP S DIR0MAP("IN")=DIR0("CIN"),DIR0MAP("OUT")=DIR0("COUT")
. E D
.. S DIR0("CIN")=$G(DIR0MAP("IN")),DIR0("COUT")=$G(DIR0MAP("OUT"))
.. S:DIR0("CIN")[(U_"KD"_U) DIR0KD=$P(DIR0("COUT"),";",$L($P(DIR0("CIN"),U_"KD"_U),U))
.. S:DIR0("CIN")[(U_"TO"_U) DIR0TO=$P(DIR0("COUT"),";",$L($P(DIR0("CIN"),U_"TO"_U),U))
;
S (DIR0A,DIR0D)=$G(DIR0A)
S:'$G(DIR0R) DIR0R=0
S:'$G(DIR0S) DIR0S=0
S:'$G(DIR0L) DIR0L=IOM-1-DIR0S
S:'$G(DIR0M) DIR0M=245
S:'$G(DIR0FLG)["r" DIR0RJ=1
;
I $G(DIR0NL)>1 D
. D EN^DIR02,END
E D INIT,^DIR01,END,PAINT
;
S X=DIR0A
I $D(DTOUT) K DTOUT S:Y="" Y="TO"
S $P(Y,U,2)=+$G(DIR0CHG)
D KILL^DDGLIB0($G(DIR0FLG))
K DIR0("CIN"),DIR0("COUT")
Q
;
INIT ;
K DTOUT
X DDGLZOSF("EOFF"),DDGLZOSF("TRMON")
S DIR0SV=$G(DIR0("L"))
S DIR0C=$S($G(DIR0C)<1:0,1:DIR0C)+1
S:DIR0C-1>$L(DIR0A) DIR0C=$L(DIR0A)+1
S (DIR0QT,DIR0QU)=0,DY=DIR0R,DX=DIR0S,DI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
. S DX=DIR0X X IOXY
E D
. S DIR0X=DIR0NC-DIR0L S:DIR0X<1 DIR0X=1
. S DX=DIR0S X IOXY
. S DIR0STR=$E(DIR0NA,DIR0X,DIR0X+DIR0L-1)
. W DIR0STR_$E(DIR0SP,$L(DIR0STR)+1,999)
. S DX=DIR0S+DIR0NC-DIR0X X IOXY
;
S DIR0A=DIR0NA,DIR0C=DIR0NC
Q
;
KILL ;
D KILL^DDGLIB0()
Q
;
;#8074 Press <PF1>H for help
;#7002 Insert^Replace
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HDIR0 4224 printed Sep 15, 2024@22:17:46 Page 2
DIR0 ;SFISC/MKO-FIELD EDITOR ;09DEC2015
+1 ;;22.2;VA FileMan;;Jan 05, 2016;Build 42
+2 ;;Per VA Directive 6402, this routine should not be modified.
+3 ;;Submitted to OSEHRA 5 January 2015 by the VISTA Expertise Network.
+4 ;;Based on Medsphere Systems Corporation's MSC FileMan 1051.
+5 ;;Licensed under the terms of the Apache License, Version 2.0.
+6 ;
SM ;
+1 NEW DIR0A,DIR0C,DIR0CH,DIR0CHG,DIR0D,DIR0F,DIR0L,DIR0M
+2 NEW DIR0P,DIR0QT,DIR0QU,DIR0R,DIR0RJ,DIR0S,DIR0SP,DIR0ST,DIR0SV,DX,DY
+3 SET DIR0P=""
if $DATA(DIR0("IN"))[0
DO GETKEY^DIR0K
+4 if $PIECE(DIR0,U,6)
SET DIR0RJ=1
+5 ;
+6 ;BEFORE THE READ, WRITE THE COMMAND LINE!
IF $GET(DDSH)
KILL DDSH
DO BOT^DDSCOM
+7 SET (DIR0A,DIR0D)=$GET(DIR("B"))
+8 SET DIR0R=$PIECE(DIR0,U)
SET DIR0S=$PIECE(DIR0,U,2)
SET DIR0L=$PIECE(DIR0,U,3)
SET DIR0M=245
+9 ;
+10 WRITE $PIECE(DDGLVID,DDGLDEL,10)
+11 SET DY=$PIECE(DIR0,U,4)
SET DX=$PIECE(DIR0,U,5)
+12 IF $DATA(DIR("A"))=11
Begin DoDot:1
+13 NEW DIX
+14 SET DIX=""
FOR
SET DIX=$ORDER(DIR("A",DIX))
if DIX=""
QUIT
Begin DoDot:2
+15 XECUTE IOXY
WRITE DIR("A",DIX)
+16 SET DY=DY+1
End DoDot:2
End DoDot:1
+17 ;
+18 IF $DATA(DIR("A"))#2
Begin DoDot:1
+19 XECUTE IOXY
WRITE DIR("A")
+20 IF DDO
IF DY=IOSL-1
WRITE $PIECE(DDGLCLR,DDGLDEL)
End DoDot:1
+21 ;
+22 ;Go do the READ
DO INIT
DO ^DIR01
+23 ;
A IF $DATA(DTOUT)
WRITE $CHAR(7)
SET DIR0A=DIR0D
+1 IF DIR0A="@"
IF DIR0D'="@"
SET DIR0A=""
+2 if DIR0CH="QT"
SET DIR0A=DIR0D
+3 SET X=DIR0A
+4 if X?1"^".E!(X?1"?".E)
SET DIR0A=DIR0D
+5 SET DIR0N=X=DIR0D
if DIR0A'=DIR0D
SET DIR0("L")=DIR0A
+6 ;
+7 DO END
DO PAINT
+8 XECUTE DDGLZOSF("EON")
XECUTE DDGLZOSF("TRMOFF")
+9 QUIT
+10 ;
+11 ;
+12 ;
EN(DIR0R,DIR0S,DIR0L,DIR0NL,DIR0A,DIR0M,DIR0C,DIR0MAP,DIR0FLG,X,Y) ;
+1 ;$Y $X length default
+2 ;Field editor
+3 NEW DIR0CH,DIR0CHG,DIR0D,DIR0F,DIR0KD,DIR0P,DIR0QT,DIR0QU
+4 NEW DIR0RJ,DIR0SP,DIR0ST,DIR0SV,DIR0TO,DX,DY
+5 ;
+6 ;BEFORE, $Y=4 AFTER $Y=0
DO INIT^DDGLIB0()
+7 ;
+8 IF $DATA(DIR0MAP)<2
Begin DoDot:1
+9 SET DIR0P="D"
+10 if $DATA(DIR0("DIN"))[0
DO GETKEY^DIR0K
End DoDot:1
+11 IF '$TEST
Begin DoDot:1
+12 SET DIR0P="C"
+13 IF $ORDER(DIR0MAP(""))!($DATA(DIR0MAP("IN"))[0)
Begin DoDot:2
+14 DO GETKEY^DIR0K
+15 KILL DIR0MAP
SET DIR0MAP("IN")=DIR0("CIN")
SET DIR0MAP("OUT")=DIR0("COUT")
End DoDot:2
+16 IF '$TEST
Begin DoDot:2
+17 SET DIR0("CIN")=$GET(DIR0MAP("IN"))
SET DIR0("COUT")=$GET(DIR0MAP("OUT"))
+18 if DIR0("CIN")[(U_"KD"_U)
SET DIR0KD=$PIECE(DIR0("COUT"),";",$LENGTH($PIECE(DIR0("CIN"),U_"KD"_U),U))
+19 if DIR0("CIN")[(U_"TO"_U)
SET DIR0TO=$PIECE(DIR0("COUT"),";",$LENGTH($PIECE(DIR0("CIN"),U_"TO"_U),U))
End DoDot:2
End DoDot:1
+20 ;
+21 SET (DIR0A,DIR0D)=$GET(DIR0A)
+22 if '$GET(DIR0R)
SET DIR0R=0
+23 if '$GET(DIR0S)
SET DIR0S=0
+24 if '$GET(DIR0L)
SET DIR0L=IOM-1-DIR0S
+25 if '$GET(DIR0M)
SET DIR0M=245
+26 if '$GET(DIR0FLG)["r"
SET DIR0RJ=1
+27 ;
+28 IF $GET(DIR0NL)>1
Begin DoDot:1
+29 DO EN^DIR02
DO END
End DoDot:1
+30 IF '$TEST
DO INIT
DO ^DIR01
DO END
DO PAINT
+31 ;
+32 SET X=DIR0A
+33 IF $DATA(DTOUT)
KILL DTOUT
if Y=""
SET Y="TO"
+34 SET $PIECE(Y,U,2)=+$GET(DIR0CHG)
+35 DO KILL^DDGLIB0($GET(DIR0FLG))
+36 KILL DIR0("CIN"),DIR0("COUT")
+37 QUIT
+38 ;
INIT ;
+1 KILL DTOUT
+2 XECUTE DDGLZOSF("EOFF")
XECUTE DDGLZOSF("TRMON")
+3 SET DIR0SV=$GET(DIR0("L"))
+4 SET DIR0C=$SELECT($GET(DIR0C)<1:0,1:DIR0C)+1
+5 if DIR0C-1>$LENGTH(DIR0A)
SET DIR0C=$LENGTH(DIR0A)+1
+6 SET (DIR0QT,DIR0QU)=0
SET DY=DIR0R
SET DX=DIR0S
SET DIR0F=DIR0S+DIR0L
+7 ;
+8 XECUTE IOXY
+9 SET DIR0SP=$JUSTIFY("",DIR0L)
if $GET(DDGLVAN)
SET DIR0SP=$TRANSLATE(DIR0SP," ","_")
+10 IF DIR0C-1>DIR0L
Begin DoDot:1
+11 WRITE $SELECT('$DATA(DDGLVAN):$PIECE(DDGLVID,DDGLDEL,6),1:"")_$EXTRACT(DIR0A,DIR0C-DIR0L,DIR0C-1)
+12 SET DX=DIR0F
End DoDot:1
+13 IF '$TEST
Begin DoDot:1
+14 WRITE $SELECT('$DATA(DDGLVAN):$PIECE(DDGLVID,DDGLDEL,6),1:"")_$EXTRACT(DIR0A,1,DIR0L)_$EXTRACT(DIR0SP,$LENGTH(DIR0A)+1,999)
+15 SET DX=DIR0S+DIR0C-1
+16 XECUTE IOXY
End DoDot:1
+17 QUIT
+18 ;
END ;
+1 ;RETURN Y FROM READER
SET Y=$PIECE("U^D^R^L^N^NB^NP^PP^SEL^EX^QT^CL^SV^RF^PRNT^MOUSE",U,$LENGTH($PIECE("^UP^DOWN^TAB^FDL^CR^NB^NP^PP^SEL^EX^QT^CL^SV^RF^PRNT^MOUSE^",U_DIR0CH_U),U))
+2 if Y=""
SET Y=$PIECE($GET(DIR0QT),U,2)
+3 NEW X,Y
SET DIR0SP=$TRANSLATE(DIR0SP,"_"," ")
+4 SET DIR0C=DIR0C-1
+5 QUIT
+6 ;
PAINT ;
+1 NEW DIR0X
+2 IF $GET(DIR0FLG)["P"
WRITE $PIECE(DDGLVID,DDGLDEL,10)
QUIT
+3 IF '$GET(DIR0RJ)
SET DIR0X=$EXTRACT(DIR0A,1,DIR0L)_$EXTRACT(DIR0SP,$LENGTH(DIR0A)+1,999)
+4 IF '$TEST
SET DIR0X=$EXTRACT(DIR0SP,$LENGTH(DIR0A)+1,999)_$EXTRACT(DIR0A,1,DIR0L)
+5 SET DX=DIR0S
XECUTE IOXY
+6 WRITE $PIECE(DDGLVID,DDGLDEL,10)_$PIECE(DDGLVID,DDGLDEL)_DIR0X_$PIECE(DDGLVID,DDGLDEL,10)
+7 QUIT
+8 ;
UPDATE(DIR0NA,DIR0NC) ;Update ans/curs pos
+1 NEW DIR0STR,DIR0X
+2 if $DATA(DIR0NA)[0
SET DIR0NA=DIR0A
+3 SET DIR0NC=$SELECT($DATA(DIR0NC)[0:DIR0C-1,1:DIR0NC)+1
+4 if DIR0NC<1
SET DIR0NC=1
+5 if DIR0NC-1>$LENGTH(DIR0NA)
SET DIR0NC=$LENGTH(DIR0NA)+1
+6 SET DIR0X=DX+DIR0NC-DIR0C
+7 ;
+8 IF DIR0A=DIR0NA
IF DIR0X'<DIR0S
IF DIR0X'>DIR0F
Begin DoDot:1
+9 SET DX=DIR0X
XECUTE IOXY
End DoDot:1
+10 IF '$TEST
Begin DoDot:1
+11 SET DIR0X=DIR0NC-DIR0L
if DIR0X<1
SET DIR0X=1
+12 SET DX=DIR0S
XECUTE IOXY
+13 SET DIR0STR=$EXTRACT(DIR0NA,DIR0X,DIR0X+DIR0L-1)
+14 WRITE DIR0STR_$EXTRACT(DIR0SP,$LENGTH(DIR0STR)+1,999)
+15 SET DX=DIR0S+DIR0NC-DIR0X
XECUTE IOXY
End DoDot:1
+16 ;
+17 SET DIR0A=DIR0NA
SET DIR0C=DIR0NC
+18 QUIT
+19 ;
KILL ;
+1 DO KILL^DDGLIB0()
+2 QUIT
+3 ;
+4 ;#8074 Press <PF1>H for help
+5 ;#7002 Insert^Replace