Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: HLDIEDBG

HLDIEDBG.m

Go to the documentation of this file.
  1. HLDIEDBG ;CIOFO-O/LJA - Direct 772 & 773 Sets DEBUG CODE ;12/29/03 10:39
  1. ;;1.6;HEALTH LEVEL SEVEN;**109**;Oct 13,1995
  1. ;
  1. ; D MENU^HLDIE to invoke debug menu. Debugger documentation included.
  1. ;
  1. D INIT^HLDIEDB1
  1. Q
  1. ;
  1. SETDEBUG ; Set or "unset" the DEBUG string...
  1. N IOBOFF,IOBON,IOINHI,IOINORM,NEWSTR,STRING,X
  1. W @IOF,$$CJ^XLFSTR("HLDIE Debug String Set/Unset Utility",IOM)
  1. W !,$$REPEAT^XLFSTR("=",IOM)
  1. ;
  1. S X="IOINHI;IOINORM" D ENDR^%ZISS
  1. ;
  1. ; Ask for a new string...
  1. W !!,"When asked for a new debug string, you may take one of the following actions:"
  1. W !!," * Enter RETURN or '^' to exit."
  1. W !," * Enter a debug string. (E.g., '1' or '1^2' or '1^1^1'.)"
  1. W !," * Enter '@' to delete the debug string, (If a debug string exists)."
  1. ;
  1. SET1 ;
  1. ; Get current DEBUG value...
  1. S STRING=$G(^XTMP("HLDIE-DEBUG","STATUS"))
  1. ;
  1. ; Show user current value...
  1. W !!!!,"Current DEBUG string = ",IOINHI,STRING,IOINORM
  1. ;
  1. ; Get new debug string...
  1. W !!,"Enter DEBUG string, ",$S(STRING]"":"'@', ",1:""),"or RETURN to exit: "
  1. R NEWSTR:999 QUIT:'$T ;->
  1. ;
  1. ; Exit conditions...
  1. I NEWSTR=U!(NEWSTR']"") D QUIT ;->
  1. . I STRING']"" D QUIT ;->
  1. . . W " no changes made. Exiting... "
  1. . . H 2
  1. . W !!,"No changes made. (If you want to stop debugging, enter '"
  1. . W IOINHI,"@",IOINORM,"'.) Exiting..."
  1. ;
  1. ; Reset to null if @...
  1. I NEWSTR="@" S NEWSTR=""
  1. ;
  1. ; User didn't change anything!!!
  1. I NEWSTR=STRING W " no changes made... " G SET1 ;->
  1. ;
  1. ; If debug string to be set to null...
  1. I NEWSTR']"" D G SET1 ;->
  1. . KILL ^XTMP("HLDIE-DEBUG","STATUS")
  1. . W " stopped all debugging!"
  1. ;
  1. ; Debug string has text, so just set it...
  1. S ^XTMP("HLDIE-DEBUG",0)=$$FMADD^XLFDT(DT,7)_U_$$NOW^XLFDT_U_"Control string for HLDIE debugging"
  1. S ^XTMP("HLDIE-DEBUG","STATUS")=NEWSTR
  1. W " debugging set..."
  1. ;
  1. Q
  1. ;
  1. ;
  1. ; ================================================================
  1. ;
  1. ;
  1. DEBUG(RTN,LOC,STORE,XEC) ; Store debug data... (Don't call unless all
  1. ; checks have been made and debug data IS to be stored!)
  1. ;
  1. ; ROOT() -- req
  1. ;
  1. ; RTN -- Where (subrtn~rtn, usually) call to FILE^HLDIE made from.
  1. ;
  1. ; LOC -- Location... BEFORE FILE^HLDIE call = 1
  1. ; AFTER FILE^HLDIE call = 2
  1. ;
  1. ; STORE -- "" = Don't collect
  1. ; 1 = Collect "select" (see above) data.
  1. ; 2 = Collect "all" data.
  1. ;
  1. ; XEC -- If XEC=1 then S STORE=$$STORE^HLDIEDB0(RTN,LOC,STORE) is
  1. ; called to optionally change the value of STORE (and thus
  1. ; control whether data is stored.)
  1. ;
  1. N CT,DEBUGNO,DEBUGNOW,HLFILE,HLIEN,INCRNO,NO,X,XTMP
  1. ;
  1. S DEBUGNOW=$$NOW^XLFDT,DT=DEBUGNOW\1
  1. ;
  1. ; Get file and ien for storing in XTMP...
  1. S FILE=$G(FILE),IEN=$G(IEN)
  1. I FILE,IEN S HLFILE=FILE,HLIEN=IEN
  1. I 'FILE!('IEN) D
  1. . S (HLFILE,HLIEN)=0
  1. . I $G(ROOT)]"" S HLFILE=$O(@ROOT@(0)),HLIEN=+$O(@ROOT@(+HLFILE,""))
  1. ;
  1. ; Get storage number...
  1. S DEBUGNO=$O(^XTMP("HLDIE-DEBUG-"_DT,$J,RTN,":"),-1)+1
  1. ;
  1. ; How many stored? Can't store more than 20...
  1. S CT=0,NO=0
  1. F S NO=$O(^XTMP("HLDIE-DEBUG-"_DT,$J,RTN,NO)) Q:'NO D
  1. . S CT=CT+1
  1. ;
  1. ; If M code passed, check w/^DIM, then execute.
  1. I XEC=1 S STORE=$$STORESCR^HLDIEDB2(RTN,LOC,STORE) QUIT:'STORE ;->
  1. ;
  1. ERRESUME ; If $$STORESCR code errors, there has to be a place for
  1. ; error trapping to GOTO. This is that place...
  1. ;
  1. ; Quit if 20 occurences stored...
  1. QUIT:CT'<20 ;->
  1. ;
  1. ; Zero node & XTMP...
  1. ;
  1. ; Debug data retained for 7 days...
  1. S XTMP="HLDIE-DEBUG-"_DT
  1. S:$G(^XTMP(XTMP,0))']"" ^XTMP(XTMP,0)=$$FMADD^XLFDT(DT,7)_U_DEBUGNOW_U_"Debug data created by HLDIEDBG routine"
  1. ;
  1. ; Xref data retain for 7 days from last time any DEBUG data created...
  1. S XTMP="HLDIE-DEBUGX"
  1. S:$G(^XTMP(XTMP,0))']"" ^XTMP(XTMP,0)=$$FMADD^XLFDT(DT,7)_U_$$NOW^XLFDT_U_"Debug data created by HLDIEDBG routine"
  1. I $P(^XTMP(XTMP,0),U)'=$$FMADD^XLFDT(DT,7) S $P(^XTMP(XTMP,0),U)=$$FMADD^XLFDT(DT,7)
  1. ;
  1. ; Get incremental number...
  1. S INCRNO=$I(^XTMP("HLDIE-DEBUGN","N"),1)
  1. ;
  1. ; Do following for STORE=1 and STORE=2...
  1. S ^XTMP("HLDIE-DEBUG-"_DT,$J,RTN,+DEBUGNO)=LOC_U_DEBUGNOW_U_$G(HLFILE)_U_$G(HLIEN)_U_$TR($P($G(XQY0),U,1,2),U,"~")_U_$TR($G(HLEDITOR),U,"~")
  1. D STOREMSG(+$G(HLFILE),+$G(HLIEN),RTN,DEBUGNO,LOC,INCRNO)
  1. ;
  1. ; Store "select" data...
  1. I STORE=1,LOC'=2,$G(ROOT)]"" D QUIT ;->
  1. . MERGE ^XTMP("HLDIE-DEBUG-"_DT,$J,RTN,+DEBUGNO)=@ROOT
  1. ;
  1. QUIT:STORE'=2 ;->
  1. ;
  1. ; Store "all" local variable data...
  1. S X="^XTMP(""HLDIE-DEBUG-"_DT_""","_$J_","""_RTN_""","_DEBUGNO_","
  1. D DOLRO^%ZOSV
  1. ;
  1. D ONLYASC(X)
  1. ;
  1. Q
  1. ;
  1. ONLYASC(REF) ; Convert control characters to {ASCII}...
  1. N DATA,LP
  1. ;
  1. S LP=$E(REF,1,$L(REF)-1)_")"
  1. F S LP=$Q(@LP) Q:LP'[REF D
  1. . S DATA=$$ONLYASC^HLDIEDB0(@LP)
  1. . I $L(DATA),$TR(DATA," ","")']"" S DATA="{#"_$L(DATA)_" spaces}"
  1. . S @LP=DATA
  1. ;
  1. Q
  1. ;
  1. STOREMSG(FILE,IEN,RTN,DEBUGNO,LOC,INCRNO) ; Store message data in ^XTMP...
  1. ; DEBUGNOW -- req
  1. N GBL,NODE
  1. ;
  1. ; Set XREF XTMP...
  1. S ^XTMP("HLDIE-DEBUGX",FILE,IEN,DEBUGNOW,$J,RTN,DEBUGNO)=LOC_U_$TR($G(HLEDITOR),U,"~")
  1. S ^XTMP("HLDIE-DEBUGN","N",INCRNO)=FILE_U_IEN_U_DEBUGNOW_U_$J_U_RTN_U_DEBUGNO_U_LOC_U_$TR($G(HLEDITOR),U,"~")
  1. ;
  1. ; Get GBL...
  1. S GBL=$S(FILE=772:"^HL(772,"_IEN_")",1:"^HLMA("_IEN_")")
  1. ;
  1. ; Collect message data...
  1. F NODE=0,1,2,"P","S",$S(FILE=772:"IN",1:"MSH") D NODE(GBL,NODE)
  1. ;
  1. Q
  1. ;
  1. NODE(GBL,NODE) ; Collect message data...
  1. ; RTN,DEBUGNO -- req
  1. N LAST,LNO,TXT,X
  1. ;
  1. I NODE="MSH" D QUIT ;->
  1. . N LNO,TXT
  1. . S LNO=0
  1. . F S LNO=$O(@GBL@("MSH",LNO)) Q:'LNO D
  1. . . S TXT=$G(@GBL@("MSH",+LNO,0)) QUIT:TXT']"" ;->
  1. . . S ^XTMP("HLDIE-DEBUG-"_DT,$J,RTN,DEBUGNO,"D","MSH",LNO,0)=TXT
  1. ;
  1. I NODE="IN" D QUIT ;->
  1. . N LAST,TXT
  1. . S LAST=$O(@GBL@("IN",":"),-1)
  1. . S TXT=$G(@GBL@("IN",1,0)) QUIT:TXT']"" ;->
  1. . S ^XTMP("HLDIE-DEBUG-"_DT,$J,RTN,DEBUGNO,"D","IN",1,0)=1_":"_LAST_"~"_TXT
  1. ;
  1. ; Store node...
  1. S X=$G(@GBL@(NODE)) I X]"" S ^XTMP("HLDIE-DEBUG-"_DT,$J,RTN,DEBUGNO,"D",NODE)=X
  1. ;
  1. Q
  1. ;
  1. KILLALL ; Don't call here unless it's OK to remove ALL-ALL debug data...
  1. N KILL,OFF,XTMP
  1. ;
  1. I $O(^XTMP("HLDIE-DEBUG"))']"HLDIE-DEBUG" D QUIT ;->
  1. . W !!,"No debug data exists..."
  1. ;
  1. W !
  1. S KILL=$$YN^HLCSRPT4("Kill **ALL** debug data","No")
  1. I 'KILL W " no data will be killed..." QUIT ;->
  1. ;
  1. W !!,"KILLing all debug data..."
  1. S XTMP="HLDIE-DEBUG"
  1. F S XTMP=$O(^XTMP(XTMP)) Q:XTMP'["HLDIE-DEBUG" D
  1. . KILL ^XTMP(XTMP)
  1. ;
  1. Q
  1. ;
  1. LOG(SUBSV,KEEP,STOP) ; Log local vars into ^XTMP("HLDIE "_DT)...
  1. ;
  1. ; Documentation in MENU^HLDIE...
  1. ;
  1. N NO,NOW,NOXTMP,X,XTMP
  1. ;
  1. ; Presets...
  1. S SUBSV=$G(SUBSV),KEEP=$G(KEEP),STOP=$G(STOP),NOXTMP=0,NOW=$$NOW^XLFDT
  1. S SUBSV=$TR($S(SUBSV]"":SUBSV,1:"UNKNOWN"),"""","")
  1. ;
  1. ; # to keep setup...
  1. S KEEP=$S(KEEP&(KEEP<100):KEEP,1:20)
  1. ;
  1. ; XTMP setup...
  1. S XTMP="HLDIE-"_DT
  1. S:'$D(^XTMP(XTMP,0)) ^XTMP(XTMP,0)=$$FMADD^XLFDT(NOW,7)_U_$$NOW^XLFDT_U_"Data logged by LOG~HLDIE"
  1. ;
  1. ; Count number entries...
  1. I STOP=1 D
  1. . S NOXTMP=0,NO=0
  1. . F S NO=$O(^XTMP(XTMP,SUBSV,NO)) Q:'NO D
  1. . . S NOXTMP=NOXTMP+1
  1. ;
  1. ; Incremented sequential store #...
  1. S NO=$O(^XTMP(XTMP,SUBSV,":"),-1)+1
  1. ;
  1. ; STOP now?
  1. I STOP,NOXTMP'<KEEP QUIT ;->
  1. ;
  1. ; Store all local variables...
  1. S X="^XTMP("""_XTMP_""","""_SUBSV_""","_NO_"," D DOLRO^%ZOSV
  1. S ^XTMP(XTMP,SUBSV,NO)=$$NOW^XLFDT
  1. ;
  1. I $ZE]"" S ^XTMP(XTMP,SUBSV,NO,"$ZE")=$ZE
  1. ;
  1. ; Keep only KEEP instances...
  1. F NO=NO-KEEP:-1:1 KILL ^XTMP(XTMP,SUBSV,NO)
  1. ;
  1. Q
  1. ;
  1. EOR ;HLDIEDBG - Direct 772 & 773 Sets DEBUG CODE ; 11/18/2003 11:17