INHOTNTM ; DGH,FRW,JSH,JPD ; 10 Dec 97 12:26; Output Controller background processor
;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
;COPYRIGHT 1991-2000 SAIC
;CHCS TLS_4603; GEN 1; 21-MAY-1999
;COPYRIGHT 1997 SAIC
;
; Input:
; INBPN - ien of output controller
; INHSRVR - Server number
; Local:
; DA - IEN of transaction
; DTTM - DATE AND TIME OF TRANSACTION
;
N X
S ^INRHB("RUN",INBPN)=$H
S X=$G(^INRHSITE(1,0)),INHANG=$P(X,U,4) S:'INHANG INHANG=10
S MODE=+$P(X,U,7),INTHROT=+$P(X,U,9)
S INCUTOFF=$P(X,U,15) S:INCUTOFF="" INCUTOFF=99999
S INHSRVMO=+$P($G(^INRHSITE(1,2)),U,1),INAVJ=$G(^%ZOSF("AVJ"))
S INFSHNG=+$P(^INRHSITE(1,2),U,2)/4 S:INFSHNG>90 INFSHNG=90
S JOB=^INTHOS(1,1)
S INHJOB(4)=$$REPLACE^UTIL(JOB,"*","SRVR^INHOTM(INBPN,INHSRVNO)")
;note - recover transaction process at some future time
;loop until server shutdown.
F Q:'$$RUN D LOOP
K ^INRHB("RUN",INBPN)
END Q ;Exit here
;
LOOP ;Main loop
D INRHB(INBPN,"Processing Transaction")
;Get next transaction from queue
S DA=$$NEXTDA(.PRIO,.DTTM),N=DTTM
I 'DA D INRHB(INBPN,"Idle") H INHANG Q
E I $$RUN D NEWSRV
Q
NEWSRV ;Try to start new server
N INLKFLG S INLKFLG=0
Q:'$$RUN
F INHSRVNO=1:1:MODE L +^INRHB("RUN","SRVR",INBPN,INHSRVNO):0 I $T D Q
.S INLKFLG=1
.;start a new job/server process
.X INAVJ
.I Y>1 D
..S ^INRHB("RUN","SRVR",INBPN,INHSRVNO)=""
..L -^INRHB("RUN","SRVR",INBPN,INHSRVNO) X INHJOB(4) I $T H INTHROT
.L -^INRHB("RUN","SRVR",INBPN,INHSRVNO)
;Hang if nothing got locked since all servers in use
I 'INLKFLG D
.D INRHB(INBPN,"Idle")
.F X=1:1:INFSHNG H 2 Q:'$$RUN
Q
RUN() ;Function to decide if routine should continue to run
;Returns 1 = YES 0 = NO
L +^INRHB("RUN",INBPN):0,-^INRHB("RUN",INBPN)
Q:'$G(^INRHSITE(1,"ACT")) 0
Q:'$D(^INRHB("RUN",INBPN)) 0
I $D(^%ZOSF("SIGNOFF")) X ^("SIGNOFF") I K ^INRHB("RUN") Q 0
Q 1
TYPE(DA) ;Return type of transaction
; Input: DA - ien of transaction
S DEST=$P($G(^INTHU(DA,0)),U,2) I 'DEST S TYPE="" Q ""
S DOM=$G(^INRHD(DEST,0)),TYPE=$S($P(DOM,U,2):1,$P(DOM,U,3)]"":2,$P(DOM,U,4)]"":3,1:0)
Q TYPE
SRVR(INBPN,INHSRVR) ;Output controller background processor - server
;INPUT
; INHSRVR - server number
; INBPN - ien for output controller
;
Q:'$G(INBPN)!'$G(INHSRVR)
L +^INRHB("RUN","SRVR",INBPN,INHSRVR):5 E Q
X $G(^INTHOS(1,2))
Q:'$$RUN
K INHER S X="ERROR^INHOTM",@^%ZOSF("TRAP")
S ^INRHB("RUN","SRVR",INBPN,INHSRVR)=$H
D SETENV
S X=$$PRIO^INHB1 X:X ^%ZOSF("PRIORITY")
;Start GIS Background process audit if flag is set in Site Parms File
N INPNAME S INPNAME=$P(^INTHPC(INBPN,0),U)
D AUDCHK^XUSAUD D:$D(XUAUDIT) ITIME^XUSAUD(INPNAME,INHSRVR)
;Set up control variables
S INHANG=$P($G(^INRHSITE(1,0)),U,4) S:'INHANG INHANG=10
S INCUTOFF=$P($G(^INRHSITE(1,0)),U,15) S:'INCUTOFF INCUTOFF=99999
;set max wait time
S INHMWAIT=$P($G(^INRHSITE(1,2)),U,2) S:'INHMWAIT INHMWAIT=60
;set server shutdown time
S INSHTDN=INHMWAIT*3
S:INSHTDN>3600 INSHTDN=3600 S:INSHTDN<900 INSHTDN=900
S MODE=0,INHWAIT=-INHANG,INSHTDN1=0
F S DEV="" Q:'$$RUN!'$$WAIT D SVLOOP
HALT ;Halt process
K ^INRHB("RUN","SRVR",INBPN,INHSRVR)
L -^INRHB("RUN","SRVR",INBPN,INHSRVR)
K ^DIJUSV(DUZ)
;Stop background process audit
D:$D(XUAUDIT) AUDSTP^XUSAUD
H
SVLOOP ;Loop through transactions in the server queue
S ^INRHB("RUN","SRVR",INBPN,INHSRVR)=$H
;Get next transaction from queue
L +^INLHSCH:3 E H INHANG Q
;Update background process audit
D:$D(XUAUDIT) ITIME^XUSAUD(INPNAME,INHSRVR)
S DA=$$NEXTDA(.PRIO,.DTTM),H=DTTM I 'DA L -^INLHSCH H INHANG Q
;Determine how to process transaction
S TYPE=$$TYPE(DA),INHWAIT=0
D KILL
L -^INLHSCH
I '$$TRANSOK Q
E D
.;Single Thread Process transaction new variables needed later
.N U,INHO,MODE,INAVJ,INJOB,INHANG,INTHROT,INCUTOFF,INHMWAIT,INHWAIT,PRIO,INSHTDN1,INSHTDN,DUZ,DTTM,SV,BP
.S BP=+$G(INBPN),SV=+$G(INHSRVR)
.N INBPN,INHSRVR S INBPN=BP,INHSRVR=SV
.;Start up a job for entry with a Transceiver Routine
.I TYPE=2 D ^INHOT(DA,1,DEV) Q
.;Start up a job for entry with a Transaction Type
.I TYPE=1 D ^INHOS(DA) Q
.;Start up a job for entry with a Mail recipient
.I TYPE=3 D ^INHOM(DA) Q
H INHANG
Q
WAIT() ;max wait time before shutting down
; Return 0 to shut down 1 to not shut down
S INHWAIT=INHWAIT+INHANG,INSHTDN1=INSHTDN1+INSHTDN
Q INHWAIT'>INHMWAIT!(INSHTDN1'>INSHTDN)
NEXTDA(PRIO,DTTM,NO) ;Get next transaction off queue
; Output: PRIO
; DTTM - Date,Time of transaction
; opt NO - Node to $Q
; Returns: DA - next transaction
N DAY,TIME K DA
S DAY=+$H,TIME=$P($H,",",2),DA=""
S:$G(NO)="" NO="^INLHSCH"
S NO=$Q(@NO)
I NO'="" D
.S P=$$QS(NO,1),DTTM=$$QS(NO,2),ND=+DTTM,NT=$P(DTTM,",",2)
.I '(P'?1.NP) D
..I P'>INCUTOFF,(ND=DAY&(NT'>TIME)!(ND<DAY)) S DA=$$QS(NO,3),PRIO=P Q
..S NO="^INLHSCH("_P_",""99999,99999"")"
..S DA=$$NEXTDA(.PRIO,.DTTM,NO)
Q +DA
TRANSOK() ;Verify transaction is ok to process
L +^INTHU(DA):1 E Q 0
S %=$$TYPE(DA)
L -^INTHU(DA)
I 'DEST K ^INLHSCH(PRIO,N,DA) S MES="Transaction has no destination." D ENO^INHE("",DA,"",MES),ULOG^INHU(DA,"E",MES) K MES Q 0
I 'TYPE D KILL S MES="Destination has no method of processing." D ENO^INHE("",DA,DEST,MES),ULOG^INHU(DA,"E",MES) K MES Q 0
Q 1
KILL ;Kill entry from INLHSCH
K ^INLHSCH(PRIO,DTTM,DA),^INLHSCH("DEST",DEST,PRIO,DA)
Q
SETENV ;Set up environment
S U="^",DUZ=.5,DUZ(0)="@",IO=""
D SETDT^UTDT
Q
INRHB(INBPN,MESS,SRVR,UPDT) ;Update background process file
; Input:
; INBPN-Background process ien
; MESS-Text
; SRVR-Server #
; LAST- 1 Update 3rd piece to $H, 0 leave 3rd piece
S UPDT=$G(UPDT)
I $G(SRVR) S $P(^INRHB("RUN","SRVR",INBPN,SRVR),U,1,2)=$H_U_MESS S:UPDT $P(^(SRVR),U,3)=$H Q
S $P(^INRHB("RUN",INBPN),U,1,2)=$H_U_MESS S:UPDT $P(^(INBPN),U,3)=$H
Q
ERROR ;Error module for server
S X="HALT^INHOTM",@^%ZOSF("TRAP")
X ^INTHOS(1,3)
D ENO^INHE("",.DA,.DEST,$S($D(INHER):INHER,1:$$ERRMSG^INHU1))
;*** SHOULD ALSO NOTE TRANSACTION IF DA EXISTS - MAY NOT BE CORRECT - MAY BE LAST DA PROCESSED
G HALT
QS(GLB,SUB) ; return subscript
; input: GLB = global reference returned from $Query
; SUB = numeric position of subscript to return
; output: returns value of subscript denoted by SUB
; mimics $QS except instead of error on bad data, just returns NULL
N I,N,P,PO,S,X,%
I SUB<1 S GLB=$TR($P(GLB,"("),"[]","||") D Q $G(X(SUB))
. I GLB["|" S X(-1)=$P(GLB,"|",2),X(-1)=$E(X(-1),2,$L(X(-1))-1),X(0)=$P(GLB,"|",1)_$P(GLB,"|",3)
. E S X(0)=GLB
S GLB=$P(GLB,"(",2),GLB=$E(GLB,1,$L(GLB)-1)
S S=1,P=1,PO=0 F S X(S)=$P(GLB,",",P,P+PO) Q:'$L(X(S)) S %=$L(X(S),"""")#2 S:% S=S+1,P=P+1+PO,PO=0 S:'% PO=PO+1 Q:S>SUB
S GLB=$G(X(SUB)),N=$E(GLB)
I 'N,N'=0 S GLB=$E(GLB,2,$L(GLB)-1),%=0 F S %=$F(GLB,"""""",%-1) Q:'% S GLB=$E(GLB,1,%-3)_""""_$E(GLB,%,999)
Q GLB
INHOTNTM ; DGH,FRW,JSH,JPD ; 10 Dec 97 12:26; Output Controller background processor
+1 ;;3.01;BHL IHS Interfaces with GIS;;JUL 01, 2001
+2 ;COPYRIGHT 1991-2000 SAIC
+3 ;CHCS TLS_4603; GEN 1; 21-MAY-1999
+4 ;COPYRIGHT 1997 SAIC
+5 ;
+6 ; Input:
+7 ; INBPN - ien of output controller
+8 ; INHSRVR - Server number
+9 ; Local:
+10 ; DA - IEN of transaction
+11 ; DTTM - DATE AND TIME OF TRANSACTION
+12 ;
+13 NEW X
+14 SET ^INRHB("RUN",INBPN)=$HOROLOG
+15 SET X=$GET(^INRHSITE(1,0))
SET INHANG=$PIECE(X,U,4)
IF 'INHANG
SET INHANG=10
+16 SET MODE=+$PIECE(X,U,7)
SET INTHROT=+$PIECE(X,U,9)
+17 SET INCUTOFF=$PIECE(X,U,15)
IF INCUTOFF=""
SET INCUTOFF=99999
+18 SET INHSRVMO=+$PIECE($GET(^INRHSITE(1,2)),U,1)
SET INAVJ=$GET(^%ZOSF("AVJ"))
+19 SET INFSHNG=+$PIECE(^INRHSITE(1,2),U,2)/4
IF INFSHNG>90
SET INFSHNG=90
+20 SET JOB=^INTHOS(1,1)
+21 SET INHJOB(4)=$$REPLACE^UTIL(JOB,"*","SRVR^INHOTM(INBPN,INHSRVNO)")
+22 ;note - recover transaction process at some future time
+23 ;loop until server shutdown.
+24 FOR
IF '$$RUN
QUIT
DO LOOP
+25 KILL ^INRHB("RUN",INBPN)
END ;Exit here
QUIT
+1 ;
LOOP ;Main loop
+1 DO INRHB(INBPN,"Processing Transaction")
+2 ;Get next transaction from queue
+3 SET DA=$$NEXTDA(.PRIO,.DTTM)
SET N=DTTM
+4 IF 'DA
DO INRHB(INBPN,"Idle")
HANG INHANG
QUIT
+5 IF '$TEST
IF $$RUN
DO NEWSRV
+6 QUIT
NEWSRV ;Try to start new server
+1 NEW INLKFLG
SET INLKFLG=0
+2 IF '$$RUN
QUIT
+3 FOR INHSRVNO=1:1:MODE
LOCK +^INRHB("RUN","SRVR",INBPN,INHSRVNO):0
IF $TEST
Begin DoDot:1
+4 SET INLKFLG=1
+5 ;start a new job/server process
+6 XECUTE INAVJ
+7 IF Y>1
Begin DoDot:2
+8 SET ^INRHB("RUN","SRVR",INBPN,INHSRVNO)=""
+9 LOCK -^INRHB("RUN","SRVR",INBPN,INHSRVNO)
XECUTE INHJOB(4)
IF $TEST
HANG INTHROT
End DoDot:2
+10 LOCK -^INRHB("RUN","SRVR",INBPN,INHSRVNO)
End DoDot:1
QUIT
+11 ;Hang if nothing got locked since all servers in use
+12 IF 'INLKFLG
Begin DoDot:1
+13 DO INRHB(INBPN,"Idle")
+14 FOR X=1:1:INFSHNG
HANG 2
IF '$$RUN
QUIT
End DoDot:1
+15 QUIT
RUN() ;Function to decide if routine should continue to run
+1 ;Returns 1 = YES 0 = NO
+2 LOCK +^INRHB("RUN",INBPN):0,-^INRHB("RUN",INBPN)
+3 IF '$GET(^INRHSITE(1,"ACT"))
QUIT 0
+4 IF '$DATA(^INRHB("RUN",INBPN))
QUIT 0
+5 IF $DATA(^%ZOSF("SIGNOFF"))
XECUTE ^("SIGNOFF")
IF $TEST
KILL ^INRHB("RUN")
QUIT 0
+6 QUIT 1
TYPE(DA) ;Return type of transaction
+1 ; Input: DA - ien of transaction
+2 SET DEST=$PIECE($GET(^INTHU(DA,0)),U,2)
IF 'DEST
SET TYPE=""
QUIT ""
+3 SET DOM=$GET(^INRHD(DEST,0))
SET TYPE=$SELECT($PIECE(DOM,U,2):1,$PIECE(DOM,U,3)]"":2,$PIECE(DOM,U,4)]"":3,1:0)
+4 QUIT TYPE
SRVR(INBPN,INHSRVR) ;Output controller background processor - server
+1 ;INPUT
+2 ; INHSRVR - server number
+3 ; INBPN - ien for output controller
+4 ;
+5 IF '$GET(INBPN)!'$GET(INHSRVR)
QUIT
+6 LOCK +^INRHB("RUN","SRVR",INBPN,INHSRVR):5
IF '$TEST
QUIT
+7 XECUTE $GET(^INTHOS(1,2))
+8 IF '$$RUN
QUIT
+9 KILL INHER
SET X="ERROR^INHOTM"
SET @^%ZOSF("TRAP")
+10 SET ^INRHB("RUN","SRVR",INBPN,INHSRVR)=$HOROLOG
+11 DO SETENV
+12 SET X=$$PRIO^INHB1
IF X
XECUTE ^%ZOSF("PRIORITY")
+13 ;Start GIS Background process audit if flag is set in Site Parms File
+14 NEW INPNAME
SET INPNAME=$PIECE(^INTHPC(INBPN,0),U)
+15 DO AUDCHK^XUSAUD
IF $DATA(XUAUDIT)
DO ITIME^XUSAUD(INPNAME,INHSRVR)
+16 ;Set up control variables
+17 SET INHANG=$PIECE($GET(^INRHSITE(1,0)),U,4)
IF 'INHANG
SET INHANG=10
+18 SET INCUTOFF=$PIECE($GET(^INRHSITE(1,0)),U,15)
IF 'INCUTOFF
SET INCUTOFF=99999
+19 ;set max wait time
+20 SET INHMWAIT=$PIECE($GET(^INRHSITE(1,2)),U,2)
IF 'INHMWAIT
SET INHMWAIT=60
+21 ;set server shutdown time
+22 SET INSHTDN=INHMWAIT*3
+23 IF INSHTDN>3600
SET INSHTDN=3600
IF INSHTDN<900
SET INSHTDN=900
+24 SET MODE=0
SET INHWAIT=-INHANG
SET INSHTDN1=0
+25 FOR
SET DEV=""
IF '$$RUN!'$$WAIT
QUIT
DO SVLOOP
HALT ;Halt process
+1 KILL ^INRHB("RUN","SRVR",INBPN,INHSRVR)
+2 LOCK -^INRHB("RUN","SRVR",INBPN,INHSRVR)
+3 KILL ^DIJUSV(DUZ)
+4 ;Stop background process audit
+5 IF $DATA(XUAUDIT)
DO AUDSTP^XUSAUD
+6 HANG
SVLOOP ;Loop through transactions in the server queue
+1 SET ^INRHB("RUN","SRVR",INBPN,INHSRVR)=$HOROLOG
+2 ;Get next transaction from queue
+3 LOCK +^INLHSCH:3
IF '$TEST
HANG INHANG
QUIT
+4 ;Update background process audit
+5 IF $DATA(XUAUDIT)
DO ITIME^XUSAUD(INPNAME,INHSRVR)
+6 SET DA=$$NEXTDA(.PRIO,.DTTM)
SET H=DTTM
IF 'DA
LOCK -^INLHSCH
HANG INHANG
QUIT
+7 ;Determine how to process transaction
+8 SET TYPE=$$TYPE(DA)
SET INHWAIT=0
+9 DO KILL
+10 LOCK -^INLHSCH
+11 IF '$$TRANSOK
QUIT
+12 IF '$TEST
Begin DoDot:1
+13 ;Single Thread Process transaction new variables needed later
+14 NEW U,INHO,MODE,INAVJ,INJOB,INHANG,INTHROT,INCUTOFF,INHMWAIT,INHWAIT,PRIO,INSHTDN1,INSHTDN,DUZ,DTTM,SV,BP
+15 SET BP=+$GET(INBPN)
SET SV=+$GET(INHSRVR)
+16 NEW INBPN,INHSRVR
SET INBPN=BP
SET INHSRVR=SV
+17 ;Start up a job for entry with a Transceiver Routine
+18 IF TYPE=2
DO ^INHOT(DA,1,DEV)
QUIT
+19 ;Start up a job for entry with a Transaction Type
+20 IF TYPE=1
DO ^INHOS(DA)
QUIT
+21 ;Start up a job for entry with a Mail recipient
+22 IF TYPE=3
DO ^INHOM(DA)
QUIT
End DoDot:1
+23 HANG INHANG
+24 QUIT
WAIT() ;max wait time before shutting down
+1 ; Return 0 to shut down 1 to not shut down
+2 SET INHWAIT=INHWAIT+INHANG
SET INSHTDN1=INSHTDN1+INSHTDN
+3 QUIT INHWAIT'>INHMWAIT!(INSHTDN1'>INSHTDN)
NEXTDA(PRIO,DTTM,NO) ;Get next transaction off queue
+1 ; Output: PRIO
+2 ; DTTM - Date,Time of transaction
+3 ; opt NO - Node to $Q
+4 ; Returns: DA - next transaction
+5 NEW DAY,TIME
KILL DA
+6 SET DAY=+$HOROLOG
SET TIME=$PIECE($HOROLOG,",",2)
SET DA=""
+7 IF $GET(NO)=""
SET NO="^INLHSCH"
+8 SET NO=$QUERY(@NO)
+9 IF NO'=""
Begin DoDot:1
+10 SET P=$$QS(NO,1)
SET DTTM=$$QS(NO,2)
SET ND=+DTTM
SET NT=$PIECE(DTTM,",",2)
+11 IF '(P'?1.NP)
Begin DoDot:2
+12 IF P'>INCUTOFF
IF (ND=DAY&(NT'>TIME)!(ND<DAY))
SET DA=$$QS(NO,3)
SET PRIO=P
QUIT
+13 SET NO="^INLHSCH("_P_",""99999,99999"")"
+14 SET DA=$$NEXTDA(.PRIO,.DTTM,NO)
End DoDot:2
End DoDot:1
+15 QUIT +DA
TRANSOK() ;Verify transaction is ok to process
+1 LOCK +^INTHU(DA):1
IF '$TEST
QUIT 0
+2 SET %=$$TYPE(DA)
+3 LOCK -^INTHU(DA)
+4 IF 'DEST
KILL ^INLHSCH(PRIO,N,DA)
SET MES="Transaction has no destination."
DO ENO^INHE("",DA,"",MES)
DO ULOG^INHU(DA,"E",MES)
KILL MES
QUIT 0
+5 IF 'TYPE
DO KILL
SET MES="Destination has no method of processing."
DO ENO^INHE("",DA,DEST,MES)
DO ULOG^INHU(DA,"E",MES)
KILL MES
QUIT 0
+6 QUIT 1
KILL ;Kill entry from INLHSCH
+1 KILL ^INLHSCH(PRIO,DTTM,DA),^INLHSCH("DEST",DEST,PRIO,DA)
+2 QUIT
SETENV ;Set up environment
+1 SET U="^"
SET DUZ=.5
SET DUZ(0)="@"
SET IO=""
+2 DO SETDT^UTDT
+3 QUIT
INRHB(INBPN,MESS,SRVR,UPDT) ;Update background process file
+1 ; Input:
+2 ; INBPN-Background process ien
+3 ; MESS-Text
+4 ; SRVR-Server #
+5 ; LAST- 1 Update 3rd piece to $H, 0 leave 3rd piece
+6 SET UPDT=$GET(UPDT)
+7 IF $GET(SRVR)
SET $PIECE(^INRHB("RUN","SRVR",INBPN,SRVR),U,1,2)=$HOROLOG_U_MESS
IF UPDT
SET $PIECE(^(SRVR),U,3)=$HOROLOG
QUIT
+8 SET $PIECE(^INRHB("RUN",INBPN),U,1,2)=$HOROLOG_U_MESS
IF UPDT
SET $PIECE(^(INBPN),U,3)=$HOROLOG
+9 QUIT
ERROR ;Error module for server
+1 SET X="HALT^INHOTM"
SET @^%ZOSF("TRAP")
+2 XECUTE ^INTHOS(1,3)
+3 DO ENO^INHE("",.DA,.DEST,$SELECT($DATA(INHER):INHER,1:$$ERRMSG^INHU1))
+4 ;*** SHOULD ALSO NOTE TRANSACTION IF DA EXISTS - MAY NOT BE CORRECT - MAY BE LAST DA PROCESSED
+5 GOTO HALT
QS(GLB,SUB) ; return subscript
+1 ; input: GLB = global reference returned from $Query
+2 ; SUB = numeric position of subscript to return
+3 ; output: returns value of subscript denoted by SUB
+4 ; mimics $QS except instead of error on bad data, just returns NULL
+5 NEW I,N,P,PO,S,X,%
+6 IF SUB<1
SET GLB=$TRANSLATE($PIECE(GLB,"("),"[]","||")
Begin DoDot:1
+7 IF GLB["|"
SET X(-1)=$PIECE(GLB,"|",2)
SET X(-1)=$EXTRACT(X(-1),2,$LENGTH(X(-1))-1)
SET X(0)=$PIECE(GLB,"|",1)_$PIECE(GLB,"|",3)
+8 IF '$TEST
SET X(0)=GLB
End DoDot:1
QUIT $GET(X(SUB))
+9 SET GLB=$PIECE(GLB,"(",2)
SET GLB=$EXTRACT(GLB,1,$LENGTH(GLB)-1)
+10 SET S=1
SET P=1
SET PO=0
FOR
SET X(S)=$PIECE(GLB,",",P,P+PO)
IF '$LENGTH(X(S))
QUIT
SET %=$LENGTH(X(S),"""")#2
IF %
SET S=S+1
SET P=P+1+PO
SET PO=0
IF '%
SET PO=PO+1
IF S>SUB
QUIT
+11 SET GLB=$GET(X(SUB))
SET N=$EXTRACT(GLB)
+12 IF 'N
IF N'=0
SET GLB=$EXTRACT(GLB,2,$LENGTH(GLB)-1)
SET %=0
FOR
SET %=$FIND(GLB,"""""",%-1)
IF '%
QUIT
SET GLB=$EXTRACT(GLB,1,%-3)_""""_$EXTRACT(GLB,%,999)
+13 QUIT GLB