ECOB2 ;BP/CMF - Utility Object
;;2.0;EVENT CAPTURE;**100**;8 May 96;Build 21
;@author - Chris Flegel
;@date - 17 May 2009
;@version - 1.0
;;
Q
;; private methods
CLASS(RESULT,HANDLE,PARAMS) ;
N JUSTIFY,OFFSET,PROPERTY,NAME,COUNT,CHILD,SCOPE
D PARSE("Handle",HANDLE)
D PARSE("Offset",PARAMS)
D SHOW^ECOB(.X,HANDLE,"Pu","_class",JUSTIFY)
D SHOW^ECOB(.X,HANDLE,"Pu","_routine",JUSTIFY)
D SHOW^ECOB(.X,HANDLE,"Pr","_parent",JUSTIFY)
; show properties only
F SCOPE="Pr","Pu" D
.S PROPERTY=""
.F S PROPERTY=$O(@HANDLE@(SCOPE,PROPERTY)) Q:PROPERTY="" D
..D SHOW^ECOB(.CHILD,HANDLE,SCOPE,PROPERTY,JUSTIFY)
..I $$ISHANDLE^ECOB(HANDLE,CHILD) D
...W !,$J(">>>----->",JUSTIFY)
...D METHOD^ECOB(.RESULT,CHILD_".Class."_OFFSET)
...W !,$J("<----<<<",JUSTIFY)
...Q
..Q
.Q
; tree out methods
S RESULT=1
Q
;;
GET(RESULT,HANDLE,METHOD,PARAMS) ;
N PROPERTY
D PARSE("Get",METHOD)
D GET^ECOB(.RESULT,HANDLE,"Pu",PROPERTY)
Q
;;
INFO(RESULT,HANDLE,PARAMS) ;
N JUSTIFY,OFFSET,PROPERTY,NAME,COUNT,CHILD
D PARSE("Handle",HANDLE)
D PARSE("Offset",PARAMS)
S PROPERTY=""
F S PROPERTY=$O(@HANDLE@("Pu",PROPERTY)) Q:PROPERTY="" D
.D SHOW(.CHILD,HANDLE,"Show"_PROPERTY,JUSTIFY)
.I $$ISHANDLE^ECOB(HANDLE,CHILD) D METHOD^ECOB(.RESULT,CHILD_".Info."_OFFSET)
.Q
S RESULT=1
Q
;;
PARSE(PARSE,VALUE) ;
I PARSE="Get" D Q
.S PROPERTY=$P(VALUE,".",1)
.S PROPERTY=$P(PROPERTY,"Get",2)
.Q
I PARSE="Handle" D Q
.S HANDLE=$P(VALUE,".")
.Q
I PARSE="Handle1" D Q
.S NAME=$P(VALUE,".",1)
.S COUNT=$P(VALUE,".",2)
.Q
I PARSE="Justify" D Q
.S JUSTIFY=$S(+VALUE:+VALUE,1:0)
.Q
I PARSE="Method" D Q
.S METHOD=$P(VALUE,".",2)
.Q
I PARSE="Offset" D Q
.S JUSTIFY=$S(+VALUE:+VALUE,1:0)
.S OFFSET=JUSTIFY+5
.Q
I PARSE="Params" D Q
.S PARAMS=$P(VALUE,".",3,99)
.Q
I PARSE="Set" D Q
.S PROPERTY=$P(VALUE,".",1)
.S PROPERTY=$P(PROPERTY,"Set",2)
.S VALUE=$P(VALUE,".",2)
.Q
I PARSE="Show" D Q
.S PROPERTY=$P(VALUE,".",1)
.S PROPERTY=$P(PROPERTY,"Show",2)
.Q
Q
;
SET(RESULT,HANDLE,METHOD,PARAMS) ;
N PROPERTY
D PARSE("Set",METHOD)
D SET^ECOB(.RESULT,HANDLE,"Pu",PROPERTY,PARAMS)
Q
;;
SHOW(RESULT,HANDLE,METHOD,PARAMS) ;
N PROPERTY
D PARSE("Show",METHOD)
D SHOW^ECOB(.RESULT,HANDLE,"Pu",PROPERTY,+PARAMS)
Q
;;
TREE(RESULT,HANDLE,PARAMS) ;
N JUSTIFY,OFFSET,PROPERTY,NAME,COUNT,CHILD,SCOPE
D PARSE("Handle1",HANDLE)
D PARSE("Offset",PARAMS)
; tree out properties
F SCOPE="Pr","Pu" D
.S PROPERTY=""
.F S PROPERTY=$O(^TMP($J,"ECHRO",NAME,COUNT,SCOPE,PROPERTY)) Q:PROPERTY="" D
..D TREE^ECOB(.CHILD,HANDLE,SCOPE,PROPERTY,JUSTIFY)
..I $$ISHANDLE^ECOB(HANDLE,CHILD) D METHOD^ECOB(.RESULT,CHILD_".Tree."_OFFSET)
..Q
.Q
; tree out methods
S RESULT=1
Q
;;
;; public methods
CREATE(NAME) ;
; call parent first
N HANDLE,CHILD
S HANDLE=$$CREATE^ECOB(NAME)
D SELF^ECOB(.RESULT,HANDLE,"EC UTILITY","Utility","METHOD^ECOB2(.RESULT,ARGUMENT)","EC BASE")
;;
; complex properties last
Q HANDLE
;;
DESTROY(HANDLE) ;
; call parent last
Q $$DESTROY^ECOB(HANDLE)
;;
METHOD(RESULT,ARGUMENT) ;
; argument=handle.method.(additional.params...)
N HANDLE,METHOD,PARAMS
D PARSE("Handle",ARGUMENT)
D PARSE("Method",ARGUMENT)
D PARSE("Params",ARGUMENT)
I METHOD="Class" D CLASS(.RESULT,HANDLE,PARAMS) Q ;;.Class.[offset] - show class info only
I $E(METHOD,1,3)="Get" D GET(.RESULT,HANDLE,METHOD,PARAMS) Q ;;.Get[aPropertyName] - returns property value
I $E(METHOD,1,3)="Set" D SET(.RESULT,HANDLE,METHOD,PARAMS) Q ;;.Set[aPropertyName].[value] - edits property value
I $E(METHOD,1,4)="Show" D SHOW(.RESULT,HANDLE,METHOD,PARAMS) Q ;;.Show[aPropertyName].[offset] - shows property value justified by offset
I METHOD="Info" D INFO(.RESULT,HANDLE,PARAMS) Q ;;.Info.[offset] - shows public properties with values justified by offset
I METHOD="Tree" D TREE(.RESULT,HANDLE,PARAMS) Q ;;.Tree.[offset] - shows all properties default values and methods justified by offset
S RESULT="0^Invalid argument"
Q
;;
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HECOB2 4109 printed Dec 13, 2024@01:57:55 Page 2
ECOB2 ;BP/CMF - Utility Object
+1 ;;2.0;EVENT CAPTURE;**100**;8 May 96;Build 21
+2 ;@author - Chris Flegel
+3 ;@date - 17 May 2009
+4 ;@version - 1.0
+5 ;;
+6 QUIT
+7 ;; private methods
CLASS(RESULT,HANDLE,PARAMS) ;
+1 NEW JUSTIFY,OFFSET,PROPERTY,NAME,COUNT,CHILD,SCOPE
+2 DO PARSE("Handle",HANDLE)
+3 DO PARSE("Offset",PARAMS)
+4 DO SHOW^ECOB(.X,HANDLE,"Pu","_class",JUSTIFY)
+5 DO SHOW^ECOB(.X,HANDLE,"Pu","_routine",JUSTIFY)
+6 DO SHOW^ECOB(.X,HANDLE,"Pr","_parent",JUSTIFY)
+7 ; show properties only
+8 FOR SCOPE="Pr","Pu"
Begin DoDot:1
+9 SET PROPERTY=""
+10 FOR
SET PROPERTY=$ORDER(@HANDLE@(SCOPE,PROPERTY))
if PROPERTY=""
QUIT
Begin DoDot:2
+11 DO SHOW^ECOB(.CHILD,HANDLE,SCOPE,PROPERTY,JUSTIFY)
+12 IF $$ISHANDLE^ECOB(HANDLE,CHILD)
Begin DoDot:3
+13 WRITE !,$JUSTIFY(">>>----->",JUSTIFY)
+14 DO METHOD^ECOB(.RESULT,CHILD_".Class."_OFFSET)
+15 WRITE !,$JUSTIFY("<----<<<",JUSTIFY)
+16 QUIT
End DoDot:3
+17 QUIT
End DoDot:2
+18 QUIT
End DoDot:1
+19 ; tree out methods
+20 SET RESULT=1
+21 QUIT
+22 ;;
GET(RESULT,HANDLE,METHOD,PARAMS) ;
+1 NEW PROPERTY
+2 DO PARSE("Get",METHOD)
+3 DO GET^ECOB(.RESULT,HANDLE,"Pu",PROPERTY)
+4 QUIT
+5 ;;
INFO(RESULT,HANDLE,PARAMS) ;
+1 NEW JUSTIFY,OFFSET,PROPERTY,NAME,COUNT,CHILD
+2 DO PARSE("Handle",HANDLE)
+3 DO PARSE("Offset",PARAMS)
+4 SET PROPERTY=""
+5 FOR
SET PROPERTY=$ORDER(@HANDLE@("Pu",PROPERTY))
if PROPERTY=""
QUIT
Begin DoDot:1
+6 DO SHOW(.CHILD,HANDLE,"Show"_PROPERTY,JUSTIFY)
+7 IF $$ISHANDLE^ECOB(HANDLE,CHILD)
DO METHOD^ECOB(.RESULT,CHILD_".Info."_OFFSET)
+8 QUIT
End DoDot:1
+9 SET RESULT=1
+10 QUIT
+11 ;;
PARSE(PARSE,VALUE) ;
+1 IF PARSE="Get"
Begin DoDot:1
+2 SET PROPERTY=$PIECE(VALUE,".",1)
+3 SET PROPERTY=$PIECE(PROPERTY,"Get",2)
+4 QUIT
End DoDot:1
QUIT
+5 IF PARSE="Handle"
Begin DoDot:1
+6 SET HANDLE=$PIECE(VALUE,".")
+7 QUIT
End DoDot:1
QUIT
+8 IF PARSE="Handle1"
Begin DoDot:1
+9 SET NAME=$PIECE(VALUE,".",1)
+10 SET COUNT=$PIECE(VALUE,".",2)
+11 QUIT
End DoDot:1
QUIT
+12 IF PARSE="Justify"
Begin DoDot:1
+13 SET JUSTIFY=$SELECT(+VALUE:+VALUE,1:0)
+14 QUIT
End DoDot:1
QUIT
+15 IF PARSE="Method"
Begin DoDot:1
+16 SET METHOD=$PIECE(VALUE,".",2)
+17 QUIT
End DoDot:1
QUIT
+18 IF PARSE="Offset"
Begin DoDot:1
+19 SET JUSTIFY=$SELECT(+VALUE:+VALUE,1:0)
+20 SET OFFSET=JUSTIFY+5
+21 QUIT
End DoDot:1
QUIT
+22 IF PARSE="Params"
Begin DoDot:1
+23 SET PARAMS=$PIECE(VALUE,".",3,99)
+24 QUIT
End DoDot:1
QUIT
+25 IF PARSE="Set"
Begin DoDot:1
+26 SET PROPERTY=$PIECE(VALUE,".",1)
+27 SET PROPERTY=$PIECE(PROPERTY,"Set",2)
+28 SET VALUE=$PIECE(VALUE,".",2)
+29 QUIT
End DoDot:1
QUIT
+30 IF PARSE="Show"
Begin DoDot:1
+31 SET PROPERTY=$PIECE(VALUE,".",1)
+32 SET PROPERTY=$PIECE(PROPERTY,"Show",2)
+33 QUIT
End DoDot:1
QUIT
+34 QUIT
+35 ;
SET(RESULT,HANDLE,METHOD,PARAMS) ;
+1 NEW PROPERTY
+2 DO PARSE("Set",METHOD)
+3 DO SET^ECOB(.RESULT,HANDLE,"Pu",PROPERTY,PARAMS)
+4 QUIT
+5 ;;
SHOW(RESULT,HANDLE,METHOD,PARAMS) ;
+1 NEW PROPERTY
+2 DO PARSE("Show",METHOD)
+3 DO SHOW^ECOB(.RESULT,HANDLE,"Pu",PROPERTY,+PARAMS)
+4 QUIT
+5 ;;
TREE(RESULT,HANDLE,PARAMS) ;
+1 NEW JUSTIFY,OFFSET,PROPERTY,NAME,COUNT,CHILD,SCOPE
+2 DO PARSE("Handle1",HANDLE)
+3 DO PARSE("Offset",PARAMS)
+4 ; tree out properties
+5 FOR SCOPE="Pr","Pu"
Begin DoDot:1
+6 SET PROPERTY=""
+7 FOR
SET PROPERTY=$ORDER(^TMP($JOB,"ECHRO",NAME,COUNT,SCOPE,PROPERTY))
if PROPERTY=""
QUIT
Begin DoDot:2
+8 DO TREE^ECOB(.CHILD,HANDLE,SCOPE,PROPERTY,JUSTIFY)
+9 IF $$ISHANDLE^ECOB(HANDLE,CHILD)
DO METHOD^ECOB(.RESULT,CHILD_".Tree."_OFFSET)
+10 QUIT
End DoDot:2
+11 QUIT
End DoDot:1
+12 ; tree out methods
+13 SET RESULT=1
+14 QUIT
+15 ;;
+16 ;; public methods
CREATE(NAME) ;
+1 ; call parent first
+2 NEW HANDLE,CHILD
+3 SET HANDLE=$$CREATE^ECOB(NAME)
+4 DO SELF^ECOB(.RESULT,HANDLE,"EC UTILITY","Utility","METHOD^ECOB2(.RESULT,ARGUMENT)","EC BASE")
+5 ;;
+6 ; complex properties last
+7 QUIT HANDLE
+8 ;;
DESTROY(HANDLE) ;
+1 ; call parent last
+2 QUIT $$DESTROY^ECOB(HANDLE)
+3 ;;
METHOD(RESULT,ARGUMENT) ;
+1 ; argument=handle.method.(additional.params...)
+2 NEW HANDLE,METHOD,PARAMS
+3 DO PARSE("Handle",ARGUMENT)
+4 DO PARSE("Method",ARGUMENT)
+5 DO PARSE("Params",ARGUMENT)
+6 ;;.Class.[offset] - show class info only
IF METHOD="Class"
DO CLASS(.RESULT,HANDLE,PARAMS)
QUIT
+7 ;;.Get[aPropertyName] - returns property value
IF $EXTRACT(METHOD,1,3)="Get"
DO GET(.RESULT,HANDLE,METHOD,PARAMS)
QUIT
+8 ;;.Set[aPropertyName].[value] - edits property value
IF $EXTRACT(METHOD,1,3)="Set"
DO SET(.RESULT,HANDLE,METHOD,PARAMS)
QUIT
+9 ;;.Show[aPropertyName].[offset] - shows property value justified by offset
IF $EXTRACT(METHOD,1,4)="Show"
DO SHOW(.RESULT,HANDLE,METHOD,PARAMS)
QUIT
+10 ;;.Info.[offset] - shows public properties with values justified by offset
IF METHOD="Info"
DO INFO(.RESULT,HANDLE,PARAMS)
QUIT
+11 ;;.Tree.[offset] - shows all properties default values and methods justified by offset
IF METHOD="Tree"
DO TREE(.RESULT,HANDLE,PARAMS)
QUIT
+12 SET RESULT="0^Invalid argument"
+13 QUIT
+14 ;;