AUTP22X ;IHS/VEN/TOAD - AUT patch 22 pre-init ;
;;98.1;AUT UPDATE;**22**;SEP 19, 2008;Build 6
;
; This is the pre-init for AUT*98.1*22. It strips all control chars
; out of the ^AUTTRLSH global prior to the install of the patch.
;
; 2008 04 18-20 Rick Marshall created this routine from scratch to
; clear out control characters found in the ^ACPT globals in both
; values and subscripts.
;
QUIT ; This routine should not be called at the top or anywhere
; else. It is only to be called at CLEANALL by KIDS as the pre-init
; for AUT*98.1*22.
;
CHECK ; troubleshooting entry point
;
N AUMNAME S AUMNAME="^AUTTRLSH" ; the name value of each node of ^AUTTRLSH
N AUMCNTC S AUMCNTC=0 ; how many nodes had control characters
N AUMCNTN S AUMCNTN=0 ; how many node names had control characters
;
N AUMCNT ; count nodes
F AUMCNT=1:1 D S AUMNAME=$Q(@AUMNAME) Q:AUMNAME="" ; walk ^AUTTRLSH
. ;
. I '(AUMCNT#1000) W "." ; indicate progress
. ;
. I AUMNAME?.E1C.E D ; if the node name contains a control char
. . S AUMCNTC=AUMCNTC+1,AUMCNTN=AUMCNTN+1 ; add to both counts
. . W "@",AUMCNT,"@",$C(7) ; note presence of control characters
. . W !,AUMNAME ; write node name
. ;
. N AUMVALU S AUMVALU=$G(@AUMNAME) ; fetch value of node
. ;
. I AUMVALU?.E1C.E D ; if the node value contains a control char
. . S AUMCNTC=AUMCNTC+1 ; add to our count of instances
. . W "=",AUMCNT,"=",$C(7) ; note presence of control characters
. . W !,AUMVALU ; write node name
;
W !!,"Number of nodes in global: ",AUMCNT
W !!,"Number of nodes with control characters: ",AUMCNTC
W !!,"Number of node names with control characters: ",AUMCNTN
QUIT ; end of CHECK
;
;
CLEANALL ; AUM*8.0*3 PRE-INIT: Remove Control Characters from ^AUTTRLSH
;
D BMES^XPDUTL($$T("MSG+9")) ; AUM*8.0*3 PRE-INIT
D MES^XPDUTL($$T("MSG+8")) ; Removing control character from your ...
;
K ^TMP("AUM",$J) ; clear scratch space
;
N AUMNAME S AUMNAME="^AUTTRLSH" ; the name value of each node of ^AUTTRLSH
N AUMCNTC S AUMCNTC=0 ; how many nodes had control characters
N AUMCNTN S AUMCNTN=0 ; how many node names had control characters
;
N AUMCNT ; count nodes, walk ^AUTTRLSH
F AUMCNT=1:1 D S AUMNAME=$Q(@AUMNAME) Q:AUMNAME=""
. ;
. I '(AUMCNT#1000) W "." ; indicate progress
. ;
. N AUMVALU S AUMVALU=$G(@AUMNAME) ; fetch value of node
. N AUMBADN S AUMBADN=AUMNAME?.E1C.E ; is it a bad name
. N AUMBADV S AUMBADV=AUMVALU?.E1C.E ; is it a bad value
. Q:'AUMBADN&'AUMBADV ; skip good nodes
. ;
. ; for output, show where control characters were
. N AUMMAPN S AUMMAPN=AUMNAME
. N AUMMAPV S AUMMAPV=AUMVALU
. ;
. N AUMCLN S AUMCLN=AUMNAME ; save cleaned up name in AUMCLN
. I AUMBADN D ; if the node name contains a control character
. . S AUMCNTC=AUMCNTC+1,AUMCNTN=AUMCNTN+1 ; add to both counts
. . W AUMCNT,$C(7),": bad name" ; note presence of control chars
. . D CLEAN(.AUMCLN,.AUMMAPN,1) ; strip out the control characters
. ;
. I AUMBADV D ; if the node value contains a control character
. . S AUMCNTC=AUMCNTC+1 ; add to our count of instances
. . W AUMCNT,$C(7),": bad value" ; note presence of control chars
. . D CLEAN(.AUMVALU,.AUMMAPV,0) ; strip out the control characters
. ;
. D MES^XPDUTL(AUMMAPN_"="_AUMMAPV_"...") ; show the problem (safely)
. ;
. I AUMBADV,'AUMBADN S @AUMNAME=AUMVALU Q ; good name but bad value
. ;
. ; what we wish we could do here is just kill the node and replace it
. ; but we would need the Millennium standard's KVALUE, which can kill
. ; just a node. We are stuck with KILL, which kills the entire tree
. ; and so would interfere with nodes we have not yet scanned and saved
. ; off. So, we have to separate the killing from the scanning & saving.
. ; For now we copy our cleaned up names and values out to ^TMP.
. N AUMEMP S AUMEMP=AUMCLN ; change name from ^AUTTRLSH(*)
. ;S $E(AUMEMP,1,6)="^TMP(""AUM"","_$J_"," ; to ^TMP("AUM",$J,*)
. S $E(AUMEMP,1,10)="^TMP(""AUM"","_$J_"," ; to ^TMP("AUM",$J,*)
. ;IHS/OIT/CLS 09/17/2008 change to equal length of global root ^AUTTRLSH(
. ; W AUMCLN," ==> ",AUMEMP ; debugging code
. S @AUMEMP=AUMVALU ; save off the cleaned up node to ^TMP
. S @AUMEMP@(U)=AUMNAME ; save off bad name with ctl chars
;
I AUMCNTN D BMES^XPDUTL($$T("MSG+7")) ; Replacing the bad node ...
;
S AUMNAME=$NA(^TMP("AUM",$J)) ; now we will traverse our saved nodes
N AUMLENG S AUMLENG=$L(AUMNAME) ; get the length of the prefix
N AUMPRE S AUMPRE=$E(AUMNAME,1,AUMLENG-1) ; & grab that prefix
; walk ^TMP("AUM",$J), exit when name no longer starts with prefix
F S AUMNAME=$Q(@AUMNAME) Q:$P(AUMNAME,AUMPRE)'=""!(AUMNAME="") D
. N AUTTRLSH S AUTTRLSH=AUMNAME,$E(AUTTRLSH,1,AUMLENG)="^AUTTRLSH(" ; change back
. K @(@AUMNAME@(U)) ; delete node in ^AUTTRLSH whose bad name we saved off
. N AUMVALU S AUMVALU=@AUMNAME ; get the saved, clean value
. S @AUTTRLSH=AUMVALU ; copy cleaned up node back into ^AUTTRLSH
. N AUMSUB S AUMSUB=$QS(AUMNAME,3) ; get the main subscript
. K @AUMNAME@(U) ; delete the saved node name to avoid it
. D MES^XPDUTL(AUTTRLSH_"="_AUMVALU) ; report nodes as we copy them back
K ^TMP("AUM",$J) ; clean up rest of temp space
;
D BMES^XPDUTL(AUMCNT-1_$$T("MSG+1")) ; # nodes in ^AUTTRLSH were scanned.
D MES^XPDUTL(AUMCNTC_$$T("MSG+2")) ; # instances of control charact...
; # of them from node names, # from values.
D MES^XPDUTL(AUMCNTN_$$T("MSG+3")_(AUMCNTC-AUMCNTN)_$$T("MSG+4"))
; Your ^AUTTRLSH global is [now] free of control characters.
D BMES^XPDUTL($$T("MSG+5")_$S(AUMCNTC:"now ",1:"")_$$T("MSG+6"))
;
QUIT ; end of CLEANALL
;
;
T(TAG) QUIT $P($T(@TAG),";;",2)
;
;
MSG ; messages to display
;; nodes in ^AUTTRLSH were scanned.
;; instances of control characters were found and removed,
;; of them from node names,
;; from values.
;;Your ^AUTTRLSH global is
;;free of control characters.
;;Replacing the bad node names found in ^AUTTRLSH
;;Removing control characters from your ^AUTTRLSH global...
;;AUM*8.0*3 PRE-INIT
;
;
CLEAN(AUMSTR,AUMMAP,AUMNAME) ; private, strip ctl chars out of a string
;
; .AUMSTR = input & output: string to clear of control characters
; .AUMMAP = output: display version of AUMSTR
; AUMNAME = 1 if this is a name, else 0, affects quotation marks
;
; code useful another time, but not here
; N AUMCHAR
; S AUMCHAR=$C(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)
; S AUMCHAR=AUMCHAR_$C(22,23,24,25,26,27,28,29,30,31,127)
; S AUMSTR=$TR(AUMSTR,AUMCHAR) ; strip out standard ASCII ctl chars
;
; traverse loop backward so our insertions do not throw off our position
; within AUMMAP. Replacing one control character with _$C(#)_ expands
; the value of AUMMAP, shifting all the character positions & throwing
; off its positional mapping to AUMSTR; we work from the end of the
; string forward so that the loss of correspondence happens in the part
; of AUMMAP we have already looked at.
;
S AUMNAME=+$G(AUMNAME) ; default to not a name
S AUMMAP=AUMSTR ; create copy to highlight the control characters
N AUMPOS ; each position
F AUMPOS=$L(AUMSTR):-1:1 D:$E(AUMSTR,AUMPOS)?1C ; for each ctl char
. N AUMCHAR S AUMCHAR=$E(AUMSTR,AUMPOS) ; copy it
. N AUMASCI S AUMASCI=$A(AUMCHAR) ; get its ASCII code
. ; replace control chars that have standard ASCII equivalents
. N AUMREPL
. S AUMREPL=$TR(AUMCHAR,$C(28,145,146,147,148,150,151),"C''""""--")
. I AUMNAME,AUMASCI=147!(AUMASCI=148) S AUMREPL="""""" ; dbl for nm
. ; I AUMASCI=153 S AUMREPL="(TM)" ; cutting legal text
. I AUMREPL?1C S AUMREPL="" ; if no replacement, delete it
. S $E(AUMSTR,AUMPOS)=AUMREPL ; replace the ctl char
. S $E(AUMMAP,AUMPOS)="_$C("_AUMASCI_")_" ; highlight it in AUMMAP
;
QUIT ; end of CLEAN
;
;
; end of routine AUM28P1
AUTP22X ;IHS/VEN/TOAD - AUT patch 22 pre-init ;
+1 ;;98.1;AUT UPDATE;**22**;SEP 19, 2008;Build 6
+2 ;
+3 ; This is the pre-init for AUT*98.1*22. It strips all control chars
+4 ; out of the ^AUTTRLSH global prior to the install of the patch.
+5 ;
+6 ; 2008 04 18-20 Rick Marshall created this routine from scratch to
+7 ; clear out control characters found in the ^ACPT globals in both
+8 ; values and subscripts.
+9 ;
+10 ; This routine should not be called at the top or anywhere
QUIT
+11 ; else. It is only to be called at CLEANALL by KIDS as the pre-init
+12 ; for AUT*98.1*22.
+13 ;
CHECK ; troubleshooting entry point
+1 ;
+2 ; the name value of each node of ^AUTTRLSH
NEW AUMNAME
SET AUMNAME="^AUTTRLSH"
+3 ; how many nodes had control characters
NEW AUMCNTC
SET AUMCNTC=0
+4 ; how many node names had control characters
NEW AUMCNTN
SET AUMCNTN=0
+5 ;
+6 ; count nodes
NEW AUMCNT
+7 ; walk ^AUTTRLSH
FOR AUMCNT=1:1
Begin DoDot:1
+8 ;
+9 ; indicate progress
IF '(AUMCNT#1000)
WRITE "."
+10 ;
+11 ; if the node name contains a control char
IF AUMNAME?.E1C.E
Begin DoDot:2
+12 ; add to both counts
SET AUMCNTC=AUMCNTC+1
SET AUMCNTN=AUMCNTN+1
+13 ; note presence of control characters
WRITE "@",AUMCNT,"@",$CHAR(7)
+14 ; write node name
WRITE !,AUMNAME
End DoDot:2
+15 ;
+16 ; fetch value of node
NEW AUMVALU
SET AUMVALU=$GET(@AUMNAME)
+17 ;
+18 ; if the node value contains a control char
IF AUMVALU?.E1C.E
Begin DoDot:2
+19 ; add to our count of instances
SET AUMCNTC=AUMCNTC+1
+20 ; note presence of control characters
WRITE "=",AUMCNT,"=",$CHAR(7)
+21 ; write node name
WRITE !,AUMVALU
End DoDot:2
End DoDot:1
SET AUMNAME=$QUERY(@AUMNAME)
IF AUMNAME=""
QUIT
+22 ;
+23 WRITE !!,"Number of nodes in global: ",AUMCNT
+24 WRITE !!,"Number of nodes with control characters: ",AUMCNTC
+25 WRITE !!,"Number of node names with control characters: ",AUMCNTN
+26 ; end of CHECK
QUIT
+27 ;
+28 ;
CLEANALL ; AUM*8.0*3 PRE-INIT: Remove Control Characters from ^AUTTRLSH
+1 ;
+2 ; AUM*8.0*3 PRE-INIT
DO BMES^XPDUTL($$T("MSG+9"))
+3 ; Removing control character from your ...
DO MES^XPDUTL($$T("MSG+8"))
+4 ;
+5 ; clear scratch space
KILL ^TMP("AUM",$JOB)
+6 ;
+7 ; the name value of each node of ^AUTTRLSH
NEW AUMNAME
SET AUMNAME="^AUTTRLSH"
+8 ; how many nodes had control characters
NEW AUMCNTC
SET AUMCNTC=0
+9 ; how many node names had control characters
NEW AUMCNTN
SET AUMCNTN=0
+10 ;
+11 ; count nodes, walk ^AUTTRLSH
NEW AUMCNT
+12 FOR AUMCNT=1:1
Begin DoDot:1
+13 ;
+14 ; indicate progress
IF '(AUMCNT#1000)
WRITE "."
+15 ;
+16 ; fetch value of node
NEW AUMVALU
SET AUMVALU=$GET(@AUMNAME)
+17 ; is it a bad name
NEW AUMBADN
SET AUMBADN=AUMNAME?.E1C.E
+18 ; is it a bad value
NEW AUMBADV
SET AUMBADV=AUMVALU?.E1C.E
+19 ; skip good nodes
IF 'AUMBADN&'AUMBADV
QUIT
+20 ;
+21 ; for output, show where control characters were
+22 NEW AUMMAPN
SET AUMMAPN=AUMNAME
+23 NEW AUMMAPV
SET AUMMAPV=AUMVALU
+24 ;
+25 ; save cleaned up name in AUMCLN
NEW AUMCLN
SET AUMCLN=AUMNAME
+26 ; if the node name contains a control character
IF AUMBADN
Begin DoDot:2
+27 ; add to both counts
SET AUMCNTC=AUMCNTC+1
SET AUMCNTN=AUMCNTN+1
+28 ; note presence of control chars
WRITE AUMCNT,$CHAR(7),": bad name"
+29 ; strip out the control characters
DO CLEAN(.AUMCLN,.AUMMAPN,1)
End DoDot:2
+30 ;
+31 ; if the node value contains a control character
IF AUMBADV
Begin DoDot:2
+32 ; add to our count of instances
SET AUMCNTC=AUMCNTC+1
+33 ; note presence of control chars
WRITE AUMCNT,$CHAR(7),": bad value"
+34 ; strip out the control characters
DO CLEAN(.AUMVALU,.AUMMAPV,0)
End DoDot:2
+35 ;
+36 ; show the problem (safely)
DO MES^XPDUTL(AUMMAPN_"="_AUMMAPV_"...")
+37 ;
+38 ; good name but bad value
IF AUMBADV
IF 'AUMBADN
SET @AUMNAME=AUMVALU
QUIT
+39 ;
+40 ; what we wish we could do here is just kill the node and replace it
+41 ; but we would need the Millennium standard's KVALUE, which can kill
+42 ; just a node. We are stuck with KILL, which kills the entire tree
+43 ; and so would interfere with nodes we have not yet scanned and saved
+44 ; off. So, we have to separate the killing from the scanning & saving.
+45 ; For now we copy our cleaned up names and values out to ^TMP.
+46 ; change name from ^AUTTRLSH(*)
NEW AUMEMP
SET AUMEMP=AUMCLN
+47 ;S $E(AUMEMP,1,6)="^TMP(""AUM"","_$J_"," ; to ^TMP("AUM",$J,*)
+48 ; to ^TMP("AUM",$J,*)
SET $EXTRACT(AUMEMP,1,10)="^TMP(""AUM"","_$JOB_","
+49 ;IHS/OIT/CLS 09/17/2008 change to equal length of global root ^AUTTRLSH(
+50 ; W AUMCLN," ==> ",AUMEMP ; debugging code
+51 ; save off the cleaned up node to ^TMP
SET @AUMEMP=AUMVALU
+52 ; save off bad name with ctl chars
SET @AUMEMP@(U)=AUMNAME
End DoDot:1
SET AUMNAME=$QUERY(@AUMNAME)
IF AUMNAME=""
QUIT
+53 ;
+54 ; Replacing the bad node ...
IF AUMCNTN
DO BMES^XPDUTL($$T("MSG+7"))
+55 ;
+56 ; now we will traverse our saved nodes
SET AUMNAME=$NAME(^TMP("AUM",$JOB))
+57 ; get the length of the prefix
NEW AUMLENG
SET AUMLENG=$LENGTH(AUMNAME)
+58 ; & grab that prefix
NEW AUMPRE
SET AUMPRE=$EXTRACT(AUMNAME,1,AUMLENG-1)
+59 ; walk ^TMP("AUM",$J), exit when name no longer starts with prefix
+60 FOR
SET AUMNAME=$QUERY(@AUMNAME)
IF $PIECE(AUMNAME,AUMPRE)'=""!(AUMNAME="")
QUIT
Begin DoDot:1
+61 ; change back
NEW AUTTRLSH
SET AUTTRLSH=AUMNAME
SET $EXTRACT(AUTTRLSH,1,AUMLENG)="^AUTTRLSH("
+62 ; delete node in ^AUTTRLSH whose bad name we saved off
KILL @(@AUMNAME@(U))
+63 ; get the saved, clean value
NEW AUMVALU
SET AUMVALU=@AUMNAME
+64 ; copy cleaned up node back into ^AUTTRLSH
SET @AUTTRLSH=AUMVALU
+65 ; get the main subscript
NEW AUMSUB
SET AUMSUB=$QSUBSCRIPT(AUMNAME,3)
+66 ; delete the saved node name to avoid it
KILL @AUMNAME@(U)
+67 ; report nodes as we copy them back
DO MES^XPDUTL(AUTTRLSH_"="_AUMVALU)
End DoDot:1
+68 ; clean up rest of temp space
KILL ^TMP("AUM",$JOB)
+69 ;
+70 ; # nodes in ^AUTTRLSH were scanned.
DO BMES^XPDUTL(AUMCNT-1_$$T("MSG+1"))
+71 ; # instances of control charact...
DO MES^XPDUTL(AUMCNTC_$$T("MSG+2"))
+72 ; # of them from node names, # from values.
+73 DO MES^XPDUTL(AUMCNTN_$$T("MSG+3")_(AUMCNTC-AUMCNTN)_$$T("MSG+4"))
+74 ; Your ^AUTTRLSH global is [now] free of control characters.
+75 DO BMES^XPDUTL($$T("MSG+5")_$SELECT(AUMCNTC:"now ",1:"")_$$T("MSG+6"))
+76 ;
+77 ; end of CLEANALL
QUIT
+78 ;
+79 ;
T(TAG) QUIT $PIECE($TEXT(@TAG),";;",2)
+1 ;
+2 ;
MSG ; messages to display
+1 ;; nodes in ^AUTTRLSH were scanned.
+2 ;; instances of control characters were found and removed,
+3 ;; of them from node names,
+4 ;; from values.
+5 ;;Your ^AUTTRLSH global is
+6 ;;free of control characters.
+7 ;;Replacing the bad node names found in ^AUTTRLSH
+8 ;;Removing control characters from your ^AUTTRLSH global...
+9 ;;AUM*8.0*3 PRE-INIT
+10 ;
+11 ;
CLEAN(AUMSTR,AUMMAP,AUMNAME) ; private, strip ctl chars out of a string
+1 ;
+2 ; .AUMSTR = input & output: string to clear of control characters
+3 ; .AUMMAP = output: display version of AUMSTR
+4 ; AUMNAME = 1 if this is a name, else 0, affects quotation marks
+5 ;
+6 ; code useful another time, but not here
+7 ; N AUMCHAR
+8 ; S AUMCHAR=$C(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21)
+9 ; S AUMCHAR=AUMCHAR_$C(22,23,24,25,26,27,28,29,30,31,127)
+10 ; S AUMSTR=$TR(AUMSTR,AUMCHAR) ; strip out standard ASCII ctl chars
+11 ;
+12 ; traverse loop backward so our insertions do not throw off our position
+13 ; within AUMMAP. Replacing one control character with _$C(#)_ expands
+14 ; the value of AUMMAP, shifting all the character positions & throwing
+15 ; off its positional mapping to AUMSTR; we work from the end of the
+16 ; string forward so that the loss of correspondence happens in the part
+17 ; of AUMMAP we have already looked at.
+18 ;
+19 ; default to not a name
SET AUMNAME=+$GET(AUMNAME)
+20 ; create copy to highlight the control characters
SET AUMMAP=AUMSTR
+21 ; each position
NEW AUMPOS
+22 ; for each ctl char
FOR AUMPOS=$LENGTH(AUMSTR):-1:1
IF $EXTRACT(AUMSTR,AUMPOS)?1C
Begin DoDot:1
+23 ; copy it
NEW AUMCHAR
SET AUMCHAR=$EXTRACT(AUMSTR,AUMPOS)
+24 ; get its ASCII code
NEW AUMASCI
SET AUMASCI=$ASCII(AUMCHAR)
+25 ; replace control chars that have standard ASCII equivalents
+26 NEW AUMREPL
+27 SET AUMREPL=$TRANSLATE(AUMCHAR,$CHAR(28,145,146,147,148,150,151),"C''""""--")
+28 ; dbl for nm
IF AUMNAME
IF AUMASCI=147!(AUMASCI=148)
SET AUMREPL=""""""
+29 ; I AUMASCI=153 S AUMREPL="(TM)" ; cutting legal text
+30 ; if no replacement, delete it
IF AUMREPL?1C
SET AUMREPL=""
+31 ; replace the ctl char
SET $EXTRACT(AUMSTR,AUMPOS)=AUMREPL
+32 ; highlight it in AUMMAP
SET $EXTRACT(AUMMAP,AUMPOS)="_$C("_AUMASCI_")_"
End DoDot:1
+33 ;
+34 ; end of CLEAN
QUIT
+35 ;
+36 ;
+37 ; end of routine AUM28P1