DIP3 ;SFISC/GFT,TKW-PRINT HEADING, PAGE, COPIES ;07:48 PM  8 Aug 2002
 ;;22.0;VA FileMan;**999**;Mar 30, 1999
 I DJ,DE]"" S DJ=DJ+1,^UTILITY("DIP2",$J,DJ)=DE,DE=""
H G G:((L?1"]".E)!($G(DDXP)=2)!($G(DDXP)=4)) I '$D(DIASKHD),'L G:$D(DALL)>9 G G PAGE
 D HD
 S DA=X D HQ^DIP31 G Q^DIP:$D(DTOUT)!($D(DUOUT)) K DIRUT,DIROUT
 S DHD=X G G:X=DA,G:$$DHD(.DHD,DK,L),H
 ;
DHD(DHD,DK,L) ;VALIDATE HEADER 'DHD' FOR FILE 'DK'
 ;   'L'=0 MEANS SILENT
 ;   CALLED BY SCREENMAN TEMPLATE EDIT
 N DC,X,Y,DIC,DD,%,DW
 I DHD?.P1"["1.E F DC=1,2 S X=$P($P(DHD,"[",DC+1),"]",1) D D^DIP21 S DIC(0)=$E("E",L)_"SF",DIC("S")="I '$D(^(""DCL"")) "_DIC("S") D IX^DIC K DIC G DHDBAD:Y<0&$L(X) I Y>0 S DHD=$P(DHD,"[",1,DC)_"["_$P(Y,U,2)_"]"_$P(DHD,"]",DC+1,9) W:L !
 I DHD'?1"W ".E Q DHD'[""""
 I DUZ(0)'="@" F %=1:2 Q:$P(DHD,"""",%,999)=""  I $P($E(DHD,3,999),"""",%)[" " G DHDBAD
 Q 1
DHDBAD Q 0
 ;
G S DHD=$G(DHD) G PUT^DIP21:$S(L?1"]".E:1,$D(DALL)>9:1,$D(DALL):0,1:$L(DE)>13!DJ),PAGE
X W $C(7),!,$$EZBLD^DIALOG(1850) S X="^" G Q^DIP ;**CCO/NI 'BAD DEVICE'
 ;
PAGE ;
 K DICOMPX,DA,IO("C") S DISUPNO=$G(DISUPNO),DIPCRIT=$G(DIPCRIT),DC=$S($G(DDXP)'=4:",",1:"") S:$D(DOUT)#2 DA=DOUT I 'L,$D(PG) S DC=C_(PG-1) K PG
EGP E  I L,DHD'="@" F X=1:1:DPP I $D(DPP(X,"F")) W !,$$EZBLD^DIALOG(7096),"1// " R X:DTIME S:'$T X=U Q:X=""  G DIP3^DIQQQ:X["?",X:X[U,DIP3:X\1'=X S DC=C_(X-1) Q  ;*CCO/NI 'START AT PAGE:'
 I $G(DIFIXPT)=1 G F2
 I $D(%ZIS)[0,$D(^%ZTSK),$D(^%ZTSCH("RUN")),$D(^%ZOSF("UCI")),$D(^DD("OS",DISYS,8)) S %ZIS="QM",%ZIS("B")=""
ZIS S:$D(IOP) DIOP=IOP D:$G(DDXP)=4 ZIS^DDXP4 D ^%ZIS S:$D(DIOP) IOP=DIOP K DIOP G X:POP
 I $G(DDXP)=4 S IOM=DDXPIOM,IOSL=$S(IOSL<DDXPIOSL:DDXPIOSL,1:IOSL),X=$S(IOM<255:IOM,1:0) X ^%ZOSF("RM")
 I $D(IOT),IOT="SDP",$D(^DD("OS",DISYS,"SDP")) G SDP
 G FREE
 ;
SDP S O=IO,DIPION=ION
 I '$D(DCOPIES) W !,$$EZBLD^DIALOG(8180) R F:DTIME G SDPCLO:F[U!'$T,SDP:F\1'=F S DCOPIES=F ;**CCO/NI NUMBER OF COPIES
O K IOP,%ZIS S:$D(IO("Q")) %ZIS="NM",IOP="Q",%ZIS("B")="",DIOQ=1 S %ZIS("A")=$$EZBLD^DIALOG(8181) ;**CCO/NI 'OUTPUT COPIES TO:'
 D ^%ZIS G SDPCLO:POP,O:IO=O
 S DOUT=$S($D(ION):ION_";"_IOM_";"_IOST,1:IO),DA=IO,IOP=DIPION_";"_IOM_";"_IOST S:$D(DIOQ) %ZIS="QN",IOP="Q;"_IOP K DIOQ D ^%ZIS
FREE S %=2,F=IOST["K",W=IOST["SINGLE"
 I $D(DIPZ),'$D(IOP),IO(0)=$I,$D(^DIPT(DIPZ,"IOM")),^("IOM")>IOM W $C(7),$$EZBLD^DIALOG(8190,^("IOM")) D YN^DICN G X:%<0,ZIS:%-1 ;**CCO/NI  'MARGIN WIDTH IS NORMALLY...'
 I IO(0)'=IO,'$D(IO("Q")),'$D(IOP)!$D(IOFREE),'W!F,IO(0)=$I,$S($D(DA):DA'=$I,1:1),$S($D(%ZIS)[0:1,1:%ZIS'["F"),$P(^DD("OS",DISYS,0),U,5) S %=2 W !,$$EZBLD^DIALOG(8191) D YN^DICN G CLO:%<0,DIP3^DIQQ:'% I %=1 ;**CCO/NI 'WANT TO FREE ..?'
 I $T!$D(IO("C")) W !,$$EZBLD^DIALOG(8192),! S IO("C")=1,X=$I,DM="" X ^DD("FUNC",7,1) K IO(1,IO) S:$D(DIOEND)#2 DIOEND(9)=DIOEND,DM="X DIOEND(9) " S DIOEND=DM_$S($D(^%ZIS("C")):"G H^XUS",1:"H") ;**CCO/NI 'TERMINAL IS FREE'
F2 S X=$G(DHD) D HD:X="" S DHD=X,X=DC
 K DC,S,N,Q,H,DA,FR,TO,DM,J,T,V,CP,DIC,DIE,DRK,DINS,DALL S O=0,DK=DI,DC=X,C=","
 G ^DIP4:$D(IO("Q")) D CLEAN^DIEFU G ^DIP5
 ;
SDPCLO S X=O G CLO1
CLO S X=IO
CLO1 X ^DD("FUNC",7,1) K:$D(IO)#2&(IO]"") IO(1,IO) G X
 ;
HD S X=$$EZBLD^DIALOG($S($D(DCL)>9:8110,$D(DIAX):8111,$D(DIAR):8112,$D(DIS)>9:8109,1:8066),$$FILENAME^DIALOGZ(+DK)) ;**CCO/NI MAKE THE HEADER
 I $D(DC(0)),$D(^DIPT(DC(0),"H")),$S('$G(^("HLANG")):1,1:^("HLANG")=$G(DUZ("LANG"))) S X=^("H") ;**CCO/NI USE TEMPLATE HEADER UNLESS IT'S WRONG LANGUAGE
 I $D(DIASKHD),$D(DHD)#2 S:DHD'["?" (DIASKHD,X)=DHD S:DIASKHD'="" (X,DHD)=DIASKHD
 Q
