PROC MIKES_MAKE_LOGICAL (MMKLOG) IS ( LITERAL INPUT, LITERAL OUTFILE, RESPONSE (RESPONSE) RESP := RESULT) BEGIN STRING OUT_STR, PART_STR, PHASE INT PART_FILE, IN_PTR, IN_CHAN, OUT_CHAN, SFLAG, FLAG BOOL END_OF_INPUT WHENEVER FLAG NE 0 THEN IF FLAG > 0 THEN SMSG("ERROR WHEN " + PHASE) RESP := FLAG RETURN ELSE SMSG("WARNING WHEN " + PHASE) SRSMSG(FLAG) FLAG := 0 FI FI @ Each file in the input is now given a currency, which is @ substituted into the original input expression. PART_STR := "" OUT_STR := "" IN_PTR := 0 END_OF_INPUT := FALSE UNTIL END_OF_INPUT DO IF IN_PTR < LENGTH INPUT THEN IN_CHAR := SUBSTR(INPUT, IN_PTR, 1) ELSE END_OF_INPUT := TRUE IN_CHAR := "" FI IF (( "&^|()" INCLUDES IN_CHAR ) OR ( END_OF_INPUT )) THEN @ The end of a file name is signalled by a logical operator or @ the end of the input string IF PART_STR NE "" THEN @ We've collected a file name in PART_STR, so get a currency @ for it AF(NAM = VAL PART_STR, LNA = PART_FILE, RES = FLAG) @ Substitute the currency in the working string OUT_STR := OUT_STR + "*" + NUMERIC(PART_FILE) PART_STR := "" FI OUT_STR := OUT_STR + IN_CHAR ELSE PART_STR := PART_STR + IN_CHAR FI IN_PTR := IN_PTR + 1 REPEAT PHASE := "CREATING " + OUTFILE + " AS *OUTPUT" CRF(NAM = VAL OUTFILE, LNA = OUTPUT, RES = FLAG) SVF(RES = FLAG) @ This next little line does the business with actually putting the @ workfiles together. It's called recursively, splitting the input @ expression into two at each level until it can go no further, then @ using LOGICALMERGEFILE to put the files together two by two. MERGEFILE := LOGICALPROCESS(OUT_STR) @ Right, that's all the hard work done. Easy, wasn't it? @ Now append the workfile pointed to by *MERGEFILE into OUTFILE. PHASE := "APPENDING *MERGEFILE TO " + OUTFILE AR(INP = *MERGEFILE, OUT = *OUTPUT, RES = FLAG) END