vhLabel ;Afdrukken etiketten via Bartender [ 11/13/2003 2:38 PM ] #define BartenderPath "\\FOP_disabled\DROPFOLDER\HALPROD01\" #define BartenderDebugPath "\\FOP_disabled\c$\BARTENDER\TestBestanden\" ; format CMulti : Local(VolgKey,ProgLabel)=Data PrintMulti(CMulti,Debug) New VolgKey,BartDevice,BartLayout,ResGroep,ResID,DebugOne,File,CGroeped,C ; Eerst groeperen volgens DEVICE and LAYOUT Set VolgKey="" For Set VolgKey=$O(CMulti(VolgKey)) Quit:VolgKey="" Do . Set ResGroep=$G(CMulti(VolgKey,"RESGROEP")) ; Zie ^RES(ResGroep,"LBLK",ResID) . Set ResID=$G(CMulti(VolgKey,"RESID")) . Quit:(ResGroep="")||(ResID="") . Set BartLayout=$G(CMulti(VolgKey,"BARTLAYOUT")) ; bv : "OLProduct6x10" . Set BartDevice=$G(CMulti(VolgKey,"BARTDEVICE")) ; bv : "\\FOP_disabled\OL VERPAK1 6X10" . Quit:(BartLayout="")||(BartDevice="") . Merge CGroeped(BartDevice,BartLayout,$I(CGroeped(BartDevice,BartLayout)))=CMulti(VolgKey) ; Afdrukken per DEVICE en LAYOUT Set (BartDevice,BartLayout)="" For Set BartDevice=$O(CGroeped(BartDevice)) Quit:BartDevice="" Do . For Set BartLayout=$O(CGroeped(BartDevice,BartLayout)) Quit:BartLayout="" Do . . Do PrintOneFileWithTryCatch(BartDevice,BartLayout,.Debug,.CGroeped) Quit ; format C : Local(ProgLabel)=Data PrintOne(C,Debug) ; data is opgeslagen in %Print2File New BartDevice,BartLayout,ResGroep,ResID,File Set ResGroep=$G(C("RESGROEP")) ; Zie ^RES(ResGroep,"LBLK",ResID) Set ResID=$G(C("RESID")) Quit:(ResGroep="")||(ResID="") Set BartLayout=$G(C("BARTLAYOUT")) ; bv : "OLProduct6x10" Set BartDevice=$G(C("BARTDEVICE")) ; bv : "\\FOP_disabled\OL VERPAK1 6X10" Quit:(BartLayout="")||(BartDevice="") "" Set File=$$CreateFile(BartDevice, BartLayout,.Debug) Quit:File="" Try { Do:$G(Debug) WriteLbl(ResGroep,ResID) Do WriteRow(ResGroep,ResID,.C) Close:File'=0 File Write:File=0 ! } Catch { New GecatchteException, NewException #dim GecatchteException As TECH.Exceptions = ##class(TECH.ExceptionHandler).Catch() Close:(File'=0) File Set NewException = ##class(TECH.Exceptions.GeneralErrorException).%New("Fout bij PrintOne") Do NewException.VoegToeInnerExceptie(GecatchteException) Do ##class(TECH.ExceptionHandler).Throw(NewException) } Quit PrintOneFileWithTryCatch(BartDevice,BartLayout,Debug,CGroeped) New VolgNr,File,C,DebugOne,ResID,ResGroep Try { Set VolgNr="" Set File=$$CreateFile(BartDevice,BartLayout,.Debug) Set:$G(Debug) DebugOne=1 For { Set VolgNr=$O(CGroeped(BartDevice,BartLayout,VolgNr)) Quit:VolgNr="" Kill C Merge C=CGroeped(BartDevice,BartLayout,VolgNr) Set ResGroep=$G(C("RESGROEP")) ; Zie ^RES(ResGroep,"LBLK",ResID) Set ResID=$G(C("RESID")) If $G(DebugOne) Do WriteLbl(ResGroep,ResID) Set DebugOne=0 Do WriteRow(ResGroep,ResID,.C) } Close:(File'=0) File Write:(File=0) ! } Catch { New GecatchteException, NewException #dim GecatchteException As TECH.Exceptions = ##class(TECH.ExceptionHandler).Catch() Close:(File'=0) File Set NewException = ##class(TECH.Exceptions.GeneralErrorException).%New("Fout bij PrintOneFileWithTryCatch") Do NewException.VoegToeInnerExceptie(GecatchteException) Do ##class(TECH.ExceptionHandler).Throw(NewException) } Quit CreateFile(BartDevice,BartLayout,Debug) New File Set File=0 Set File=$$OPEN^vhDEV($S($G(Debug):$$$BartenderDebugPath,1:$$$BartenderPath),"Lbl"_$I(^Bartender)_".TXT","W","M") If ^Bartender>9999999 Lock +^Bartender Set ^Bartender=0 Lock -^Bartender Use File Write "%BTW% /AF=""C:\Bartender\Templates\"_BartLayout_".btw"" /PRN="""_BartDevice_""" /R=3 /P /D=",$C(13,10) Write "%END%",$C(13,10) Quit File CreateFileFromOld(Dev,ResGroep,LabelSize,LabelType) Set File=0 Set File=$$OPEN^vhDEV($$$BartenderPath,"Lbl"_$TR($ZH,".","_")_".TXT","W","M") Use File Set BartenderPrinter="EasyCoderPD41" Set BartenderPrinter="//FOP_disabled/HALUX 10x10" Set:LabelSize="5x10" BartenderPrinter="//FOP_disabled/PD41 HALUX 5x10" Set BartenderPrinter=$TR(BartenderPrinter,"/","\") Set BartenderLabelType=LabelType Set:LabelType="ALG" BartenderLabelType="KlantGEN10x10" Set:LabelType="CHARGE" BartenderLabelType="KlantGENBARCHARGE10x10" Set:LabelType="ALGBARC" BartenderLabelType="KlantGENBAR10x10" Set:LabelType="ALG5x10" BartenderLabelType="KlantGEN5x10" Set:LabelType="ASM" BartenderLabelType="KlantASM5x10" Set:LabelType="KAD" BartenderLabelType="KlantKAD10x10" Set:LabelType="TBX" BartenderLabelType="KlantTBX10x10" Set:LabelType="TBXCOM" BartenderLabelType="KlantTBX5x10" Set:LabelType="TBXBAR" BartenderLabelType="KlantTBXBAR10x10" Set:LabelType="OLPRODUCT" BartenderLabelType="OLProduct6x10" Set:LabelType="OLDOOS" BartenderLabelType="OLDoos6X10" Write "%BTW% /AF=""C:\Bartender\Templates\"_BartenderLabelType_".btw"" /PRN="""_BartenderPrinter_""" /R=3 /P /D=",$C(13,10) Write "%END%",$C(13,10) ;Do WriteLbl(ResGroep,LabelType) Quit File GeefWaardeVanPrintRef(PrintRef) ; LET OP : deze functie maakt gebruik van VEEL globale variabelen !!! Dus niet zomaar verplaatsen naar ProcedureBlock methods. Quit @PrintRef VervangNietPrintbareKaraktersDoorSpatie(Tekst) Set Tekst = $Translate(Tekst,$Char(9)_$Char(10)_$Char(13)_$Char(0)," ") Quit Tekst ; Alleen nodig voor titel WriteLbl(ResGroep,ResID) New Delim,VolgNr,Rec,Lbl,Last Set Delim=$C(9) Set Last=$O(^RES(ResGroep,"LBLK",ResID,""),-1) Set VolgNr="" For Set VolgNr=$O(^RES(ResGroep,"LBLK",ResID,VolgNr)) Quit:VolgNr="" Do . Set Rec=^RES(ResGroep,"LBLK",ResID,VolgNr) . Set Lbl=$P(Rec,"`") . Write Lbl . Write:VolgNr