VistA-WorldVistAEHR/r/TOOLKIT-AWCM-XD-XIN-XPAR-XQ.../XTFC1.m

99 lines
4.4 KiB
Mathematica

XTFC1 ;SF-ISC.SEA/JLI - FLOW CHART GENERATION ;12/7/95 14:50
;;7.3;TOOLKIT;**8**;Apr 25, 1995
SETIT ;
W:IOST["C-" "."
S XTX1B=$P(XTXB," ",1),XTXB=$P(XTXB," ",2,999),XTX1=$E(X,1,$L(XTX1B)),X=$E(X,$L(XTX1B)+2,$L(X))
F XTIJ=0:0 Q:XTX1B="" S XTX2B=$P(XTX1B,",",1),XTX1B=$P(XTX1B,",",2,999),XTX2=$E(XTX1,1,$L(XTX2B)),XTX1=$E(XTX1,$L(XTX2)+2,$L(XTX1)) D SETIT1
Q
SETIT1 ;
N % D PSET S:(XTNAM["DO"!(XTNAM["GOTO"))&($P(XTX2,"(")'["^") %=$P(XTX2,"(",2,99),XTX2=$P(XTX2,"(")_"^"_XTROU_$S($L(%):"("_%,1:"")
S XTENTR=XTENTR+1,^TMP($J,XTLEV,"FC",XTENTR,XTNAM)=XTOFF_XTL1_XTX2_XTL2 D QTCHK,PCLR
Q
;
DO I $E(XTXB,1,6)'="&ARGLS"&(XTXB'="") S XTNAM="DO ",XTL1="[ ",XTL2=" ]" G SETIT
I $D(XTEXT(0)) D S XTENTR=XTENTR+1,^TMP($J,XTLEV,"FC",XTENTR,"ARGLS")=XTOFF_"[REPEAT OF LAST ARGLESS DO "_XX_"]" S X=$P(X," ",2,999),XTXB=$P(XTXB," ",2,999) Q
. S XX="" F ENAD1=1:1:(XTDPER+1) S XX=XX_"."
S XTEXTB(XTDPER+1)=$P(XTXB," ",2,999),XTEXT(XTDPER+1)=$P(X," ",2,999),XTOFF(XTDPER+1)=XTOFF,XTIFLG(XTDPER+1)=XTIFLG,XTFFLG(XTDPER+1)=XTFFLG,XTCOND(XTDPER+1)=XTCOND
D S X="",XTXB="",XTENTR=XTENTR+1,^TMP($J,XTLEV,"FC",XTENTR,"ARGLS")=XTOFF_"-- START OF ARGLESS DO "_XX_"--"
. S XX="" F ENAD1=1:1:(XTDPER+1) S XX=XX_"."
Q
ENAD ; END OF NON ARGUMENT DO
D S XTENTR=XTENTR+1,^TMP($J,XTLEV,"FC",XTENTR,"ENAD ")=XTOFF_"-- END OF ARGUMENTLESS DO "_XX_"--"
. S XX="" F ENAD1=1:1:XTDPER S XX=XX_"."
. S XTOFF=XTOFF(XTDPER),XTIFLG=XTIFLG(XTDPER),XTCOND=XTCOND(XTDPER),XTFFLG=XTFFLG(XTDPER)
Q
;
GO S XTNAM="GOTO ",XTL1="{ ",XTL2=" }" G SETIT
;
KILL S XTNAM="PROC ",XTL1="KILL ",XTL2="" G SETIT
;
LOCK S XTNAM="PROC ",XTL1="LOCK ",XTL2="" G SETIT
MERGE S XTNAM="MERGE",XTL1="MERGE ",XTL2="" G SETIT
ESTART S XTNAM="ESTAR",XTL1="ESTART ",XTL2="" G SETIT
ESTOP S XTNAM="ESTOP",XTL1="ESTOP ",XTL2="" G SETIT
;
ETRIG S XTNAM="ETRIG",XTL1="ETRIGGER ",XTL2="" G SETIT
;
NEW S XTNAM="PROC ",XTL1="NEW ",XTL2="" G SETIT
;
JOB S XTNAM="JOB ",XTL1="JOB ",XTL2="" G SETIT
;
BREAK S XTNAM="PROC ",XTL1="BREAK ",XTL2="" G SETIT
;
CLOSE S XTNAM="PROC ",XTL1="CLOSE ",XTL2="" G SETIT
;
OPEN S XTNAM="PROC ",XTL1="OPEN ",XTL2="" G SETIT
;
USE S XTNAM="PROC ",XTL1="USE ",XTL2="" G SETIT
;
SET S XTNAM="PROC ",XTL1="SET ",XTL2="" G SETIT
VIEW S XTNAM="VIEW ",XTL1="VIEW ",XTL2="" G SETIT
ZCMND S XTNAM="ZCMND",XTL1=XTXO_" ",XTL2="" G SETIT
;
HALT ;
S XTX1B=$P(XTXB," ",1),XTXB=$P(XTXB," ",2,999),XTX1=$E(X,1,$L(XTX1B)),X=$E(X,$L(XTX1B)+2,$L(X)),XTENTR=XTENTR+1,^TMP($J,XTLEV,"FC",XTENTR,"HALT ")=XTOFF_" *** "_$S(XTX1>0:"HANG "_(+XTX1),1:"HALT")_" ***"
Q
;
READ ;
S XTX1B=$P(XTXB," ",1),XTXB=$P(XTXB," ",2,999),XTX1=$E(X,1,$L(XTX1B)),X=$E(X,$L(XTX1B)+2,$L(X)),XTENTR=XTENTR+1,^TMP($J,XTLEV,"FC",XTENTR,"READ ")=XTOFF_"READ--- "_XTX1
Q
;
WRITE ;
S XTX1B=$P(XTXB," ",1),XTXB=$P(XTXB," ",2,999),XTX1=$E(X,1,$L(XTX1B)),X=$E(X,$L(XTX1B)+2,$L(X)),XTENTR=XTENTR+1,^TMP($J,XTLEV,"FC",XTENTR,"WRITE")=XTOFF_"WRITE--- "_XTX1
Q
;
XECUT ;
S XTX1B=$P(XTXB," ",1),XTXB=$P(XTXB," ",2,999),XTX1=$E(X,1,$L(XTX1B)),X=$E(X,$L(XTX1B)+2,$L(X)),XTENTR=XTENTR+1,^TMP($J,XTLEV,"FC",XTENTR,"PROC ")=XTOFF_"Xecute "_XTX1
Q
QUIT ; Quit command
S XTX1B=$P(XTXB," ",1),XTXB=$P(XTXB," ",2,999),XTX1=$E(X,1,$L(XTX1B)),X=$E(X,$L(XTX1B)+2,$L(X))
S XTENTR=XTENTR+1,^TMP($J,XTLEV,"FC",XTENTR,"QUIT ")=XTOFF_$S(XTFFLG=0:" *** QUIT"_$S(XTX1'="":" "_XTX1,1:"")_" ***",1:"( QUIT FOR "_$S(XTX1'="":" "_XTX1_" ",1:"")_")") I 'XTFFLG&(XTOFF="") S XTTFLG=1
Q
;
IF ;
S XTX2B=$P(XTXB," ",1),XTXB=$P(XTXB," ",2,999),XTX1=$E(X,1,$L(XTX2B)),X=$E(X,$L(XTX2B)+2,$L(X))
S XTCOND=XTCOND+1,XTIFLG=XTIFLG+1,XTENTR=XTENTR+1,^TMP($J,XTLEV,"FC",XTENTR,"IF ")=XTOFF_"< "_XTX1_" >",XTOFF=XTOFF_"...."
Q
;
FOR ;
S XTXB1=$P(XTXB," ",1),XTXB=$P(XTXB," ",2,999),XTX1=$E(X,1,$L(XTXB1)),X=$E(X,$L(XTXB1)+2,999),XTENTR=XTENTR+1
S ^TMP($J,XTLEV,"FC",XTENTR,"FOR ")=XTOFF_"F "_$S($E(XTX1,1,6)="&ARGLS":"",1:XTX1),XTOFF=XTOFF_" ",XTFFLG=1
Q
;
ELSE ;
S XTENTR=XTENTR+1,XTCOND=XTCOND+1,XTIFLG=XTIFLG+1,^TMP($J,XTLEV,"FC",XTENTR,"ELSE ")=XTOFF_"< ELSE... >",XTOFF=XTOFF_"...."
Q
PSET ; Set post-conditional if it applies
S XTPCOND=$S(XTX2B[":":1,1:0) Q:'XTPCOND
S XTX2B=$P(XTX2B,":",1),XTXCOND=$E(XTX2,$L(XTX2B)+2,$L(XTX2)),XTX2=$E(XTX2,1,$L(XTX2B))
S XTCOND=XTCOND+1,XTENTR=XTENTR+1,^TMP($J,XTLEV,"FC",XTENTR,"DECIS")=XTOFF_"< "_XTXCOND_" >",XTOFF=XTOFF_"...."
Q
;
PCLR ;
Q:'XTPCOND
S XTCOND=XTCOND-1,XTOFF=$E(XTOFF,1,$L(XTOFF)-4)
Q
QTCHK ; Check if Quit Flag should be set
I XTNAM="GOTO "!(XTNAM="HALT ") I XTOFF="" S XTTFLG=1
Q