1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
* Code written by Rolf Kjoeller.
* This is to convert a syntax file into VB-syntax which may then be copied and pasted intodded
	a script.

SET MPRINT=yes.
DEFINE publish (!POSITIONAL !CMDEND)

/* the syntaxfile is read as data; empty lines are deleted */
DATA LIST FILE=!1 /#text(A250) .
SELECT IF NOT RTRIM(#text) EQ "" .

/* double-quotes are replaced with single-quotes */
LOOP IF RINDEX(#text,'"') GT 0 .
  COMPUTE #pos=RINDEX(#text,'"') .
  COMPUTE #text=CONCAT(SUBSTR(#text,1,#pos-1),"'",SUBSTR(#text,#pos+1)) .
END LOOP .

/* strCommands are added */
STRING text (A250) .
IF RTRIM(#text) NE "" text=CONCAT('strCommand = strCommand &','"',RTRIM(LTRIM(#text)),'" & vbCrLf') .

/* the resulting script-code is listed:
PRESERVE .
SET WIDTH=250 .
LIST CASES /VARIABLES text .
RESTORE .

!ENDDEFINE .

* Call macro with the path of the file to be converted.
publish "d:\\data\\syntax\\distributions\\Tests for significant differences in proportion.SPS" .