How to read a .QSP file and strip off all the text leaving only those commands that are for the program
The attached spec REMOVETEXT.SPX reads a .QSP file and strips off all the text leaving only those commands that are for the program. You can use this to compare two specs that are written in different languages, but you want to make sure that they are otherwise identical.
Change the Input define to match the name of the .QSP file you want to read.
Change the Output define to be the name of the file you want to create and then can use for comparison.
>Define @Input ssnycs2e.Qsp>Define @Output ssnycs2e.CMP****************** DON'T MODIFY ANYTHING BELOW THIS *********************>PurgeSame~In @Input ASCII=800 study=Orig numbuf=3~In $ study=Copy newbuf~In $ study=Temp newbuf~Output @Output ASCII TrimBlanks Len=300~DefHeader: [1#1]Continue: [2#1]Recode: [3#1]Proc=Reform:'Save the following line IF:'1) It starts with a { - Start of a question'2) It starts with a ! - If statement, RDG, MISC, or TYPE line'3) It starts with a > - Meta Command'4) It is the first line to start with a ['5) Or it is a continuation lineIf [1#"{","!",">"] or (Temp!Header = False And [1#"["]) or Temp!Continue = True WriteCase ''Copy the current line into the holding area and blank the continue flag Copy Copy![1.310] = [1.310] Modify Temp!Continue = False ''If there is an ampersand anywhere in the line then start reading the ''line backwards until you find the last character on the line. If it ''is an ampersand, set the continue flag to true If [1,...,300#"&"] Then While Maxtimes=301 Copy![301^B] And Copy![1.300^NB] Copy Copy![2.300] = Copy![1.300] If Copy![301#"&"] Error "Got Continue Case" [1.80$] Modify Temp!Continue = True Endif EndWhile Endif ''If line starts with a [ then you have now seen the header and want to ''make the header flag true, so you know you have seen it. If [1#"["] Modify Temp!Header = True Endif ''If the line starts with !CAT or !FLD then it will be followed by a ''recode table, so set the Recode flag to True so you know you are now ''looking for recode items. If it is anything else then turn off the flag If [1.4#"!CAT","!FLD"] Modify Temp!Recode = True Else Modify Temp!Recode = False Endif ''Skip over the recode table processing Goto DoneEndif'If the Recode Flag is on and this line starts a "[" for SamesAS line, or a "("'a response item then continue processing.If Temp!Recode = True And [1#"(","["] ''If it starts with a [, then just write the entire line and goto the end If [1#"["] WriteCase Goto Done Endif'If it starts with a ( then find what column the close paren is, then skip into'the next block so you can figure out where the response code ends.>Repeat $A=2,...,21; $B=5,...,24 If [$A.2#") "] Goto Column$B Endif>EndRepeat'Once you are in this block, you are reading the response codes. As soon as'you find a blank, you have the end of the response code, so blank the rest'of the line and write out what is left.>Repeat $A=5,...,30 Column$A: If [$A^B] Blank [$A-300] WriteCase Goto Done Endif>EndRepeatEndifDone: }~Exc Proc=Reform on Orig~End