#include %occInclude #include %VHMacro #define MAXLOCALSIZE 32768 // ========================================================================================================================================== // Name : GenerateRes // Author : Tom Rombaut // Function: Items aan ^RES global toevoegen aan de hand van #Defines in een INC bestand // Group kan bijv PRINTING zijn // INCFileName bevat de naam van het INC bestand (zonder INC) waar de #defines zich bevinden // Resource is de naam van de resource, bijv PAPERSIZE // ResourceOms is de omschrijving van de resource // DefinePrefix is de prefix (kleine letters) die elke constante van de resource moet voorafgaan, bijv psA3, psA4, psA5,... // ProcessPrevLineComment, indien ingesteld op true wordt de commentline voor de define als oms aanschouwt // ========================================================================================================================================== GenerateRes(Group,INCFileName,Resource,ResourceOms,DefinePrefix,ProcessPrevLineComment) If '$D(Group) Do Quit . w "PARAMS: Group,INCFileName,Resource,ResourceOms,DefinePrefix,ProcessPrevLineComment",!! Set Group=$ZCVT(Group,"U") Set Resource=$ZCVT(Resource,"U") Set ProcessPrevLineComment=$G(ProcessPrevLineComment,0) Kill ^RES(Group,"PI",Resource) Set ^RES(Group,"PI",Resource)=ResourceOms_"`"_$H_"`````````````````1" New Loop,Line,Key,KeyVal,Cnt,PrevLine Set Cnt=0 Set Loop="" Set Line="" For Set Loop=$O(^rINC(INCFileName,0,Loop)) Quit:(Loop="") Do . Set PrevLine=Line . Set Line=^rINC(INCFileName,0,Loop) . Do grAddRes(Line,PrevLine,.Cnt) w !,"Processed: "_Cnt,! Quit grAddRes(Line,PrevLine,Cnt) #Define rtnIsWhiteSpaceChar(%v) ("9,32"[$ASCII(%v)) New Loop,MaxLoop,InDefine,Char,InMacroName,MacroName,RunningToKey,InKey,Key,RunningToOms,InOms,Oms Set Loop=1 Set InDefine=0 Set InMacroName=0 Set MacroName="" Set RunningToKey=0 Set InKey=0 Set Key="" Set RunningToOms=0 Set InOms=0 Set Oms="" Set MaxLoop=$L(Line) For Quit:(Loop>MaxLoop) Do . Set Char=$E(Line,Loop) . If 'InOms && RunningToOms && (Char=";") Do Quit .. Set InOms=1 .. Set RunningToOms=0 .. Set Loop=Loop+1 . If InOms Do Quit .. Set Oms=Oms_Char .. Set Loop=Loop+1 . If RunningToKey && (Char="""") Do Quit ;Key is mogelijk een string .. Set InKey=1 .. Set RunningToKey=0 .. Set Loop=Loop+1 . If RunningToKey && '$$$rtnIsWhiteSpaceChar(Char) Do Quit ;Key kan ook een integer zijn .. Set InKey=1 .. Set RunningToKey=0 .. Set Key=Char .. Set Loop=Loop+1 . If InKey Do .. If (Char="""") || $$$rtnIsWhiteSpaceChar(Char) Do ... Set InKey=0 ... Set RunningToOms=1 .. Else Do ... Set Key=Key_Char . If 'InDefine && (Char="#") Do Quit .. Set Loop=Loop+1 .. Set:($ZCVT($E(Line,Loop,Loop+5),"U")="DEFINE") InDefine=1 .. Set Loop=Loop+6 . If InDefine && 'InMacroName && '$$$rtnIsWhiteSpaceChar(Char) Do Quit ;9=tab, 32=spatie .. Set InMacroName=1 .. Set InDefine=0 .. Set MacroName=Char .. Set Loop=Loop+1 . If InMacroName Do .. If $$$rtnIsWhiteSpaceChar(Char) Do ... Set RunningToKey=1 ... Set InMacroName=0 .. Else Do ... Set MacroName=MacroName_Char . Set Loop=Loop+1 Quit:($E(MacroName,1,$L(DefinePrefix))'=DefinePrefix) If Key="" Do Quit . w "Key must be string: "_MacroName,! Quit:($E(MacroName,$L(DefinePrefix)+1)'=$ZCVT($E(MacroName,$L(DefinePrefix)+1),"U")) ;na de prefix hoort een hoofdletter te komen, dit checken Quit:('ProcessPrevLineComment && (MacroName["(")) ;Indien macro '(' bevat: skippen Set Cnt=Cnt+1 If ProcessPrevLineComment Do . Set PrevLineComment=$P(PrevLine,";",2) . Set Oms=$P(PrevLineComment,"\",1) . Set Params=$P(PrevLineComment,"\",2) Else Do . Set Oms=MacroName . Set Params="" Set ^RES(Group,"PI",Resource,"D",Key)=Cnt_"`"_Oms_"`"_Params w $J(Key,10)_": "_Oms,! Quit // ========================================================================================================================================== // Name : CompilePackages // Author : Wim Vermeulen // Function: Alle klasses compileren door het aflopen van alle packages // Via een exclude-list en/of include-list kunnen beperkingen opgelegd worden (TO DO) // // Uit te voeren in Terminal: Do CompilePackages^vhTools() // ========================================================================================================================================== CompilePackages() ; New CompileOptions,PckgName,Key,blnPauseBetween Set CompileOptions="c-okfv" Set blnPauseBetween=1 ; Loop through packages : For Quit Do . Set PckgName="WS" . Do $system.OBJ.CompilePackage(PckgName,CompileOptions) . Read:(blnPauseBetween) Key Quit // ========================================================================================================================================== // Name : BackupLicense // Author : Wim Vermeulen // Function: Om het verloop van de Cache licensies te kunnen opvolgen: // kopieert de file all.dmp naar all_bck.dmp en voert een nieuwe DumpLocalAll() uit. // de nieuwe .dmp file kan via compareIt vergeleken worden met de bck-versie ervan. // // Uit te voeren in Terminal: Do BackupLicense^vhTools(.LastDmp) // ========================================================================================================================================== BackupLicense(LastFN) ; LastFN als .local doorgeven #define AllDmpFN "all.dmp" #define BckDmpFN "all_bck.dmp" New BckFN,sc If $L($G(LastFN))&&(LastFN[$$$AllDmpFN) Do . Set BckFN=$$$Replace(LastFN,$$$AllDmpFN,$$$BckDmpFN) . Set sc=##class(%Library.File).CopyFile(LastFN,BckFN) . w "Create backup file:"_$S('sc:" NOT",1:"")_" successfull (from '"_LastFN_"' to '"_BckFN_"')",!,! Else Do . w "No LastDmp file. Creating first dump file ...",!,! Set LastFN=$SYSTEM.License.DumpLocalAll() Quit // ========================================================================================================================================== // Name : TakeSnapshot // Author : Tom Rombaut // Function: Neem een 'snapshot', te gebruiken in het visuele programma 'ObjLeakDetector' // ========================================================================================================================================== TS(ID,Filter,RemoveWhenContainsFilter) Quit:('$D(ID)) "Er is geen ID opgegeven." If $zobjnext(0)=0 Do Quit "No registered objects." . Set ^tmpSnapShots(ID)=$LB(0,$H) Kill ^tmpSnapShots(ID) New ORef,Count,tmpClass Set (Count,ORef)=0 If $G(Filter)'="" Do . Set RemoveWhenContainsFilter=$G(RemoveWhenContainsFilter,1) . If RemoveWhenContainsFilter Do .. For Set ORef=$zobjnext(ORef) Quit:(+ORef=0) Do ... Quit:($P(ORef,"@",2)="") ... Set tmpClass=ORef.%ClassName(1) ... Quit:(tmpClass[Filter) ... Set ^tmpSnapShots(ID,ORef)=tmpClass ... Set Count=Count+1 . Else Do .. For Set ORef=$zobjnext(ORef) Quit:(+ORef=0) Do ... Quit:($P(ORef,"@",2)="") ... Set tmpClass=ORef.%ClassName(1) ... Quit:(tmpClass'[Filter) ... Set ^tmpSnapShots(ID,ORef)=tmpClass ... Set Count=Count+1 Else Do . For Set ORef=$zobjnext(ORef) Quit:(+ORef=0) Do .. Quit:($P(ORef,"@",2)="") .. Set tmpClass=ORef.%ClassName(1) .. Set ^tmpSnapShots(ID,ORef)=tmpClass .. Set Count=Count+1 Set ^tmpSnapShots(ID)=$LB(Count,$H) Quit Count_" class(es)" // ========================================================================================================================================== // Name : ArrayToText (en afgeleiden) // Author : WIM VERMEULEN // Function: Converteert een array naar text: nodes doorlopen via $QUERY, values omzetten via $$LCVT^vhLib. // Ref is de referentie naar de array, is dus type string, of via $Name(MyArray). // Kan ook één enkele subnode(+descendants) van de array doorlopen: subnodes in Ref specifiëren. // 3 verschillende modes: // - Local array of %array of Global: // * $$ArrayToText^vhLib("MyArray") // * $$ArrayToText^vhLib("MyArray(""subnode"",""snode2"")") // - Array binnen ProcedureBlock routine: --> RefArray als .local doorgeven // De Ref hoeft hier niet gelijk te zijn aan de naam van de doorgegeven array // * $$ArrayToText^vhLib("MyArray",.MyArray) // * $$ArrayToText^vhLib("MyAr",.MyArray) // * $$ArrayToText^vhLib("MyAr(""subnode"",""snode2"")",.MyArray) // - MultiDimensional property van een Object: // * $$ArrayToText^vhLib("MyObj.MDimPropt",MyObj) ; Meest eenvoudige oproep: PropertyName wordt afgeleid uit Ref --> MDimPropt // * $$ArrayToText^vhLib("MyObj.MDP" ,MyObj,"MDimPropt") ; PropertyName overruled de waarde van Ref --> MDimPropt // * $$ArrayToText^vhLib("obj.MDP ,MyObj,"MDimPropt") ; ObjNaam in Ref vrij te kiezen, is puur informatief // * $$ArrayToText^vhLib("obj.MDP(""sn"")",MyObj,"MDimPropt") ; Eén enkel niveau/subnode --> MDimPropt("sn",...) // * $$ArrayToText^vhLib("MDP ,MyObj,"MDimPropt") ; ObjNaam in Ref weggelaten, dan is MDimPropt VERPLICHT gegeven // ========================================================================================================================================== ArrayToText(Ref,RefArray,ProptName) ; RefArray als .local doorgeven, tenzij het een object is // Converteert een Array naar Text #define IsMultiDimPropt ($L($G(ProptName)))||(Ref?.AN1"."1.AN0.1(1"(".E1.")")) Quit:($G(Ref)="") New DevObj,txt Set DevObj=##class(%GlobalCharacterStream).%New() If ($IsObject($G(RefArray)))&&($$$IsMultiDimPropt) Do . Do ArrayToTextMultiDimProptW(Ref,RefArray,.ProptName,DevObj) ; RefArray is a Caché Object Else If $D(RefArray) Do . Do ArrayToTextProcBlockW(Ref,.RefArray,DevObj) Else Do . Do ArrayToTextW(Ref,DevObj) Do DevObj.Rewind() Set txt=DevObj.Read($$$MAXLOCALSIZE) Do DevObj.%Close() Quit txt ArrayToTextW(Ref,DevObj) // Schrijft een Array naar Text-CharacterStream (DevObj=0 : write to screen) Quit:($G(Ref)="") Quit:('$D(@Ref)) New Node,PatternRef Do:($D(@Ref)#10) attWrite(Ref_"="_$$LCVTCHK(@Ref)) Quit:($D(@Ref)<10) ; Else : ook de SubNodes converteren naar Text Set PatternRef="1"""_$$$Replace($S($E(Ref,$L(Ref))=")":$E(Ref,1,$L(Ref)-1) ,1:Ref),"""","""""")_""".E" Set Node=Ref For Set Node=$Q(@Node) Quit:(Node'?@PatternRef) Do . Do attWrite($C(13,10)_Node_"="_$$LCVTCHK(@Node)) Quit attWrite(sText) If +$G(DevObj,0) Do . Do DevObj.Write(sText) Else Do . Write sText Quit ArrayToTextProcBlockW(Ref,RefArray,DevObj) ; RefArray als .local doorgeven // Schrijft een Array naar Text-CharacterStream (DevObj=0 : write to screen) #define ReplaceNodeRef(%v) $$REPLACE^vhRtn1(%v,"RefArray",ArrayName,,1) Quit:($G(Ref)="") Quit:('$D(RefArray)) New RefOrig,ArrayName,Node,PatternRef Set RefOrig=Ref Set ArrayName=$P(RefOrig,"(",1) Set $P(Ref,"(",1)="RefArray" Do:($$$aHasData(@Ref)) attWrite(RefOrig_"="_$$LCVTCHK(@Ref)) Quit:('($$$aHasSubNodes(@Ref))) ; Else : ook de SubNodes converteren naar Text Set PatternRef="1"""_$$$Replace($S($E(Ref,$L(Ref))=")":$E(Ref,1,$L(Ref)-1) ,1:Ref),"""","""""")_""".E" Set Node=Ref For Set Node=$Q(@Node) Quit:(Node'?@PatternRef) Do . Do attWrite($C(13,10)_$$$ReplaceNodeRef(Node)_"="_$$LCVTCHK(@Node)) Quit ArrayToTextMultiDimProptW(Ref,obj,ProptName,DevObj) // Schrijft een MultiDimensional property van obj naar Text-CharacterStream (DevObj=0 : write to screen) #define ReplaceNodeRef(%v) $$REPLACE^vhRtn1(%v,ObjPropt,ProptRef,,1) #define BaseQueryLength 5 Quit:($G(Ref)="") New RefOrig,Ref2,ObjPropt,ProptRef,Node,PatternRef Set RefOrig=Ref Set ProptRef=$P(Ref,"(",1) Set:($G(ProptName)="") ProptName=$$$LastPiece(ProptRef,".") Set ObjPropt="obj."_ProptName Set $P(Ref,"(",1)=ObjPropt Do:($$$aHasData(@Ref)) attWrite($$$ReplaceNodeRef(Ref)_"="_$$LCVTCHK(@Ref)) Quit:('($$$aHasSubNodes(@Ref))) ; Else : ook de SubNodes converteren naar Text Set Node=$Q(@Ref) ; Convert obj.ProptName(...) to $ZOBJVAL($ZOBJREF(143),5,0,0,0,...) Set ProptRef=ProptRef_"(" Set ObjPropt=$P(Node,",",1,$$$BaseQueryLength)_"," Set Ref2=$S(RefOrig'["(":ObjPropt, 1:$$$Replace(RefOrig,ProptRef,ObjPropt)) Set PatternRef="1"""_$$$Replace($S($E(Ref2,$L(Ref2))=")":$E(Ref2,1,$L(Ref2)-1) ,1:Ref2),"""","""""")_""".E" For Quit:(Node'?@PatternRef) Do Set Node=$Q(@Node) . Do attWrite($C(13,10)_$$$ReplaceNodeRef(Node)_"="_$$LCVTCHK(@Node)) Quit attDetermineBaseQueryLength() // Om het exact aantal subnodes van ZObjVal te bepalen: // --> $O(obj.Propt("")) opvragen en kijken op welk subniveau (subnode) deze waarde voorkomt in $Query() // Voor de eenvoud: HARD CODED : Quit $$$BaseQueryLength MDToText(obj,ProptName) // Wrapper voor ArrayToTextMultiDimProptW() via ArrayToText(ref,obj,propt) in mode 3 // ProptName is een MultiDimensional property van het object obj, en wordt uitgeschreven als een array (.local) #define MDPropToText(%o,%p) $$ArrayToText(%p,%o,%p) Quit $$$MDPropToText(obj,ProptName) // ========================================================================================================================================== // Name : ArrayToTextWF // Author : WIM VERMEULEN // Function: Schrijft een Array naar Text-file. Geeft leeg of een ErrorMsg terug. // Default: Overwrite mode; [hetvolgende lukt niet: Gebruik WrAttrib="WS" om aan de file toe te voegen ] // ========================================================================================================================================== ArrayToTextWF(Ref,FilePath,WrAttrib) Quit:($G(FilePath)="") "" Set WrAttrib=$G(WrAttrib,"WSN") New OutF,sc Set OutF=##class(%Library.File).%New(FilePath) Set sc=OutF.Open(WrAttrib) ; "WSN" Quit:('sc) sc Do ArrayToTextW^vhLib(Ref,OutF) Set OutF="" Quit "" // ========================================================================================================================================== // Name : ArrayToTextEx // Author : WIM VERMEULEN (aangepast door Manuel Bauwens) // Function: Converteert een Array naar Text // ========================================================================================================================================== ArrayToTextEx(Ref,max) Quit:($G(Ref)="") "" Quit:('$D(@Ref)) "" New txt,Node,cnt Set txt="" Set:($D(@Ref)#10) txt=txt_Ref_"="_@Ref Quit:($D(@Ref)<10) txt ; Else : ook de SubNodes converteren naar Text Set Node=Ref Set cnt=0 For Set Node=$Q(@Node) Quit:(Node="") Quit:cnt>max Do . Set cnt=cnt+1 . Set txt=txt_$C(13,10)_Node_"="_$$LCVTCHK(@Node) ; $$LCVT^vhLib(@Node) Set:($E(txt,1,2)=$C(13,10)) $E(txt,1,2)="" Quit txt // ========================================================================================================================================== // Name : ArrayToTabDelim // Author : WIM VERMEULEN // Function: Converteert een array naar TAB-delimited text: nodes doorlopen via $QUERY, "single values" worden ge-append; // indien $LB(values) dan omgezet naar TAB-delim values (eerste level); bij geneste $LB's: for each item: $$LCVT^vhLib(item). // arData als .local doorgeven // FilePath : volledige naam van output bestand (incl. directory) // indien leeg, wordt de output als String teruggegeven (Max. 32768 char.) // arConfig als .local doorgeven : bevat de opmaak voor de Tab-delimited output, zoals Headers, alignment, NodeMatch,... // ========================================================================================================================================== ArrayToTabDelim(arData,FilePath,WrAttrib,arConfig) New DevObj,OutTxt New OutF,sc If $G(FilePath)="" Do Quit OutTxt . Set OutTxt="" . Set DevObj=##class(%GlobalCharacterStream).%New() . Do ArrayToTabDelimW(.arData,DevObj,.arConfig) . Do DevObj.Rewind() . Set OutTxt=DevObj.Read($$$MAXLOCALSIZE) . Set DevObj="" ; DevObj.%Close() ; Else ; write to file Set WrAttrib=$G(WrAttrib,"WSN") Set OutF=##class(%Library.File).%New(FilePath) Set sc=OutF.Open(WrAttrib) ; "WSN" Quit:($$$ISERR(sc)) sc Do ArrayToTabDelimW(.arData,OutF,.arConfig) Set OutF="" Quit "" attGetSampleConfig() Set arConfig("HDR","KLNr","Vnr","IN/OUT",$C(0),"LT","LD","CB")=$LB("Prs","other") Set arConfig("REF")="MyArray" Quit ArrayToTabDelimW(arData,DevObj,arConfig) // Schrijft een Array naar een TAB-delimited Text-CharacterStream // DevObj is het Stream-obj, verplicht mee te geven. Quit:('$D(arData)) Quit:('$IsObject($G(DevObj))) New Tab,Node,i,CntNodes,arHeaders,sLine ,blnFormatNum,blnAlignValues,NameRef Set Tab=$C(9) d:('$D(arConfig)) attGetSampleConfig() Set blnFormatNum=$G(blnFormatNum,1) Set blnAlignValues=$G(blnAlignValues,1) Set NameRef=$G(arConfig("REF")) ; NameRef is de naam van de doorgegeven array, of een alias indien gewenst door de user. Merge arHeaders=arConfig("HDR") Set Ref=$Name(arData) Set CntNodes=$S(blnAlignValues:$$attGetMaxNodes(Ref), 1:0) Do:($$$aHasSubNodes(arHeaders)) attTabbedColHeaders() Do:($$$aHasData(arData)) attbWrite(Ref_$S(blnAlignValues:$$attAddTabs(CntNodes),1:"")_Tab_":"_Tab_$$attFormatTabbedList(arData)_$$$CRLF) ; HoofdNode Set Node=Ref For Set Node=$Q(@Node) Quit:(Node="") Do . Set sLine=NameRef ; $QSubscript(Node,0) . For i=1:1:$QLength(Node) Set sLine=sLine_Tab_$QSubscript(Node,i) . Set sLine=sLine_$S(blnAlignValues:$$attAddTabs(CntNodes-$QLength(Node)),1:"")_Tab_":"_Tab_$$attFormatTabbedList(@Node) . Do attbWrite(sLine_$$$CRLF) Quit attGetMaxNodes(Ref) New tmpCnt,Node Set tmpCnt=0 Set Node=Ref For Set Node=$Q(@Node) Quit:(Node="") Set:($QLength(Node)>tmpCnt) tmpCnt=$QLength(Node) Quit tmpCnt attTabbedColHeaders() Set Node=$Name(arHeaders) For Set Node=$Q(@Node) Quit:(Node="") Do . Set sLine="" . For i=1:1:$QLength(Node) Set sLine=sLine_Tab_$QSubscript(Node,i) . Set sLine=sLine_$S(blnAlignValues:$$attAddTabs(CntNodes-$QLength(Node)),1:"")_Tab_":"_Tab_$$attFormatTabbedList(@Node) . Do attbWrite(sLine_$$$CRLF) Quit attAddTabs(Num) Quit $S(Num>0:$TR($J(" ",Num)," ",Tab), 1:"") attFormatTabbedList(Value,blnForceLCVT) #define ifFormatNum(%v) (blnFormatNum)&&($IsValidNum(%v)) #define doFormatNum(%v) $TR($FN(%v,"."),".","") Quit:($G(Value)="") "" Quit:('$$IsList(Value)) $S($$$ifFormatNum(Value):$$$doFormatNum(Value), 1:Value) ; LB is een zuivere single value Quit:($G(blnForceLCVT,0)) $$LCVT(Value) New i,txt Set txt=$LG(Value,1) For i=2:1:$LL(Value) Set txt=txt_Tab_$$attFormatTabbedList($LG(Value,i),1) ; Recursieve oproep met blnForceLCVT=1, anders opnieuw Tab-delim Quit txt attbWrite(sText) If $IsObject(DevObj) Do . Do DevObj.Write(sText) Else Do . Write sText Quit LCVTCHK(LB) Quit $$LCVT^vhLib(LB) LCVT(LB) Quit $$LCVT^vhLib(LB) IsList(LB) Quit $$IsList^vhLib(LB) // ========================================================================================================================================== // Name : MoveListItems // Author : Wim Vermeulen // Function: Moves a group of list items (itmFirst to itmLast incl) to a new position, i.e. after itmMoveTo. // // ========================================================================================================================================== // Parameters: // ----------- // If blnMoveAfter=0, the group will be moved before the itmMoveTo. // Numeric values can be used to point directly at the position in the list. Add prefix $C(0) to identify integer values in lbItems. // itmMoveTo=-1 and blnMoveAfter=1 : move to end // itmMoveTo=-1 and blnMoveAfter=0 : move to front // itmMoveTo=0 : ALWAYS move to front // lbItems kan als .local doorgegeven worden en zal dan de gewijzigde versie bevatten. // Alternatief wordt het resultaat ook 'return-value' van de routine gegeven. MoveListItems(lbItems,itmFirst,itmLast,itmMoveTo,blnMoveAfter) Set blnMoveAfter=$G(blnMoveAfter,1) #define DoLBDelete(%lb,%i) Set $LI(%lb,%i,%i)="" #define DoLBDeleteFromTo(%lb,%i,%j) Set $LI(%lb,%i,%j)="" #define LBConcat(%lb1,%lb2,%after) $S(%after:%lb1_%lb2, 1:%lb2_%lb1) Quit:($LL(lbItems)<2) "" New Pos1,Pos2,PosNew,lbMoveIt,lbBackup Set Pos1=$LF(lbItems,itmFirst) Set Pos2=$LF(lbItems,itmLast) Quit:('Pos1)||('Pos2) lbItems Set lbMoveIt=$LI(lbItems,Pos1,Pos2) d WL^vhDBG($$$LCVT("lbMoveIt: "_lbMoveIt)) Set:($LF(lbMoveIt,itmMoveTo)>0) lbBackup=lbItems ; if itmMoveTo is contained in 'items to be moved', then it will cause an error, unless itmMoveTo ALSO occurs elsewhere in the lbItems. // Indien itmMoveTo een positie aangeeft, dan eerst deze positie bepalen If itmMoveTo<0 Do . Set PosNew=-1 . Set itmMoveTo="" Else If itmMoveTo=0 Do ; Always move to the front of lbItems . Set PosNew=-1 . Set blnMoveAfter=0 . Set itmMoveTo="" Else If itmMoveTo?1.9N Do ; if starts with $C(0), it will not pass the pattern match --> position via $LF(lbItems,itmMoveTo) . Set PosNew=itmMoveTo . Set itmMoveTo=$LG(lbItems,PosNew) . Set:(itmMoveTo="")&&(PosNew>$LL(lbItems)) PosNew=-1 // Remove group from lbItems $$$DoLBDeleteFromTo(lbItems,Pos1,Pos2) // Determine position via $LF(lbItems,itmMoveTo) If '$IsValidNum($G(PosNew)) Do . Set:($E(itmMoveTo,1)=$C(0)) $E(itmMoveTo,1)="" . Set PosNew=$LF(lbItems,itmMoveTo) . d WL^vhDBG("Item "_itmMoveTo_" at pos "_PosNew_" in $List.") . If PosNew=0 Do . . d WL^vhDBG("Item "_itmMoveTo_" Not found in $List. Items will be appended.") . . Set PosNew=-1 . . Set itmMoveTo="" // Move group to new position If PosNew=-1 Do . Set lbItems=$$$LBConcat(lbItems,lbMoveIt,blnMoveAfter) ; Append of insert in front Else Do . Set $LI(lbItems,PosNew,PosNew)=$$$LBConcat($LB(itmMoveTo),lbMoveIt,blnMoveAfter) Quit lbItems // ========================================================================================================================================== // Name : DEBUG (zie vhTools.MAC) // Author : WIM VERMEULEN // Function: Schrijft debug gegevens (Waarde) naar een Global (GlobalN via Ref), // het subniveau wordt automatisch verhoogd indien UseCounter // ========================================================================================================================================== DEBUG(GlobalN,HoofdNode,SubNode,Waarde,UseCounter) New Ref,RetVal,XCmd,i Set HoofdNode=$G(HoofdNode,"1") If $L($G(SubNode)) Do . If SubNode["," Do .. Set XCmd="Set Ref=$Na("_GlobalN_"("_$$dbgQuoteNodes(HoofdNode_","_SubNode)_"))" .. Xecute XCmd . Else Do .. Set Ref=$Na(@GlobalN@(HoofdNode,SubNode)) Else Do . Set Ref=$Na(@GlobalN@(HoofdNode)) ; Debug action at Node @Ref If Waarde="$KILL" Do . Kill @Ref Else If +$G(UseCounter) Do . Set @Ref=$G(@Ref)+1 . Set @Ref@(@Ref)=Waarde . Set RetVal=@Ref Else Do . Set @Ref=Waarde Quit $G(RetVal) dbgQuoteNodes(Nodes) New Nd For i=1:1:$L(Nodes,",") Set Nd=$P(Nodes, ",", i) Do . Set:(Nd="") $P(Nodes, ",", i)="." . If '$IsValidNum(Nd), $E(Nd,1)'="""", $E(Nd,$L(Nd))'="""" Set $P(Nodes,",",i)=""""_Nd_"""" Quit Nodes // ========================================================================================================================================== // Name : GetStack // Author : TOM ROMBAUT // Function: Geeft de huidige stack weer, bruikbaar tijdens debugging // Laatste level worden niet getoond aangezien deze besteed is aan het oproepen van de forlus // ========================================================================================================================================== GetStack(Short,QuitAtSource) Set Short=$G(Short,0) Set QuitAtSource=$G(QuitAtSource,$C(0)) SET $ECODE="" FOR loop=1:1:$STACK(-1)-1 Quit:($STACK(loop,"MCODE")[QuitAtSource) DO . If Short Do .. Write $STACK(loop,"MCODE"),?5,"[PLACE: '"_ $STACK(loop,"PLACE") _ "']",! . Else Do .. WRITE !,"Context level: ",loop .. WRITE !,?5,"- Context type : ",$STACK(loop) .. WRITE !,?5,"- Current place : ",$STACK(loop,"PLACE") .. WRITE !,?5,"- Current source: ",$STACK(loop,"MCODE") .. WRITE ! QUIT // ========================================================================================================================================== // Name : GetStackToString // Author : PAUL VERHULST // Function: Plaatst de stack in een string, de lijnen worden gescheiden met $$$CRLF, bruikbaar voor creatie van de email bij errortrapping // Laatste level worden niet getoond aangezien deze besteed is aan het oproepen van de forlus // ========================================================================================================================================== GetStackToString(Short,NoLastLevels) New loop,Body Set Short=$G(Short,0) Set QuitAtSource=$G(QuitAtSource,$C(0)) Set NoLastLevels=$G(NoLastLevels,1) Set Body="" ;"Ecode: "_$ECODE Set $ECODE="" For loop=0:1:$STACK(-1)-NoLastLevels Quit:($STACK(loop,"MCODE")[QuitAtSource) DO . If Short Do .. Set Body=Body_$STACK(loop,"MCODE")_" [PLACE: '"_$STACK(loop,"PLACE") _ "']"_$$$CRLF . Else Do .. Set Body=Body_$$$CRLF_"Context level: "_loop .. Set Body=Body_$$$CRLF_" - Context type : "_$STACK(loop) .. Set Body=Body_$$$CRLF_" - Current place : "_$STACK(loop,"PLACE") .. Set Body=Body_$$$CRLF_" - Current source: "_$STACK(loop,"MCODE") Set Body=Body_$$$CRLF_$$$CRLF_"Server: "_$ZU(110)_" NameSpace: "_$ZU(5) Quit Body // ========================================================================================================================================== // Name : IsTerminal // Author : Tom Rombaut // Function: Parameter IO, bepaalt of IO een terminal-sessie is of niet. Indien geen parameter, dan wordt de huidige $io genomen // ========================================================================================================================================== IsTerminal(IO) Set IO=$G(IO,$IO) Quit IO?1"|TNT|".E1":".N1"|".N // ========================================================================================================================================== // Name : GetTerminalList // Author : Tom Rombaut // Function: Verkrijg een lijst($lb) met alle openstaande terminals, booleaanse parameter bepaalt of uw eigen job er ook mag bijzitten // ========================================================================================================================================== GetTerminalList(ExcludeSelf) New JobList,Loop,Info,TermList,Job Set JobList=$$GetJobList^vhLib() Set TermList="" Set ExcludeSelf=$G(ExcludeSelf,0) For Loop=1:1:$LL(JobList) Do . Set Job=$LI(JobList,Loop) . Do JobInfo^%SS(Job,.Info) . Quit:(ExcludeSelf && (Job=$J)) . Set:($$IsTerminal^vhLib(Info("P"))) TermList=TermList_$LB(Job) Quit TermList