Index: vhLABEL.mac.rou =================================================================== diff -u -r59222 -r59259 --- vhLABEL.mac.rou (.../vhLABEL.mac.rou) (revision 59222) +++ vhLABEL.mac.rou (.../vhLABEL.mac.rou) (revision 59259) @@ -6,6 +6,7 @@ ; 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 @@ -21,18 +22,7 @@ Set (BartDevice,BartLayout)="" For Set BartDevice=$O(CGroeped(BartDevice)) Quit:BartDevice="" Do . For Set BartLayout=$O(CGroeped(BartDevice,BartLayout)) Quit:BartLayout="" Do - . . Set VolgNr="" - . . Set File=$$CreateFile(BartDevice,BartLayout,.Debug) - . . Set:$G(Debug) DebugOne=1 - . . For Set VolgNr=$O(CGroeped(BartDevice,BartLayout,VolgNr)) Quit:VolgNr="" Do - . . . 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 ! + . . Do PrintOneFileWithTryCatch(BartDevice,BartLayout,Debug,CGroeped,ResID,ResGroep) Quit ; format C : Local(ProgLabel)=Data @@ -46,12 +36,51 @@ Quit:(BartLayout="")||(BartDevice="") "" Set File=$$CreateFile(BartDevice, BartLayout,.Debug) Quit:File="" - Do:$G(Debug) WriteLbl(ResGroep,ResID) - Do WriteRow(ResGroep,ResID,.C) - Close:File'=0 File - Write:File=0 ! + 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,ResID,ResGroep) + New VolgNr,File,C,DebugOne + 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 @@ -89,6 +118,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 @@ -126,7 +159,7 @@ . . . ;do WLIP^vhDBG(15,"Before:"_Print) . . . Set:Print["{" Print=$$REPLACE5^vhRtn1(Print,"{","$$Label^vhLABEL(""","}",""")") ; label vervangen door $$Label^vhLABEL("label") . . . ;do WLIP^vhDBG(15,"After:"_Print) - . . . Write $$VervangNietPrintbareKaraktersDoorSpatie(@(Print)) + . . . Write $$VervangNietPrintbareKaraktersDoorSpatie($$GeefWaardeVanPrintRef(Print)) . . Write:VolgNr