Skip to content

Instantly share code, notes, and snippets.

@radum
Created November 14, 2012 08:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save radum/4070908 to your computer and use it in GitHub Desktop.
Save radum/4070908 to your computer and use it in GitHub Desktop.
SublimeText 2 IBM SPSS Dimensions (build system, syntax higlight, snippets, etc)

SublimeText 2 IBM SPSS Dimensions

Build System

Place the SPSS Metadata Validator.sublime-build to {instalation_path}\Sublime Text\Data\Packages\User

Change the path to ProjectValidator.mrs so that it will match you preferences.

It only validates files ending in .mdd-metadata but you can change this as you like in the build file.

After you place the file just select from Tools\Build System the SPSS Metadata Validator option and the press CTRL+B

Syntax highlighting

Place the SPSS Metadata (mdd metadata).tmLanguage file to {installation_path}\Sublime Text\Data\Packages\User

The files need to be .mdd-metadata to be automatically recognized.

Snippets

Place SPSS - Question Template.sublime-snippet in {installation_path}\Sublime Text\Data\Packages\User

Now create a new file (CTR+N) and write spssqtpl and then press TAB it will create a basic question template for you to use.

Examples

Build System

example screen

:: If you want to use a batch file try this. Make a shortcut and drag n drop the file to be validated on it
Call "mrScriptCL.exe" "{path_to_mrs_validator}\ProjectValidator.mrs" /a:mddpath=%1
PAUSE
'@author radum, alexA
'#define metadatafile "Fields.txt"
'#define outputmdd "readmetadata.mdd"
debug.Log("Loading...")
Dim MDM, DSC, DSCs, Errortext, outputmdd
Const metadatafile = mddpath
outputmdd = metadatafile + ".mdd"
debug.Log("File to validate: "+CText(metadatafile))
' Use ShellExecute function to call MS-DOS batch file to create the RDB database
' Create the Data source component Collection
Set DSCs = CreateObject("MRDSCReg.Components")
' Find the SPSS Statistics SAV DSC
Set DSC = DSCs["mrScriptMDsc"]
' Create an MDM Document from the .sav file
on error resume next
Set MDM = DSC.Metadata.Open(metadatafile)
if err.Number<>0 then
debug.Log("All power to forward shields. Prepare to fire all weapons!")
debug.Log("Metadata errors found:")
ErrorText = CText(Err.Number) + ": " + Err.Description
debug.log(errortext)
ErrorText = ""
else
debug.Log("Okay. Time circuit's on. Flux capacitor, fluxing.")
debug.Log("Engine running. All right.")
MDM.IncludeSystemVariables = True
debug.Log("Saveing MDD file ...")
' Save the MDM document out to an .mdd file that we will use in the file transfer.
MDM.Save(outputmdd)
debug.Log("Saved")
end if
MDM.Close()
<snippet>
<content><![CDATA[
<mrSubTemplate>
<mrData QuestionElement="Error" ShowErrors='TopMost' />
<div id="question">
<mrData QuestionElement="Label" />
<mrData QuestionElement="Controls" />
</div>
</mrSubTemplate>
]]></content>
<tabTrigger>spssqtpl</tabTrigger>
</snippet>
{
"comment": "SPSS Dimensions Metadata Syntax: versio 0.1.0",
"name": "SPSS Metadata",
"scopeName": "source.mdd-metadata",
"fileTypes": ["mdd-metadata"],
"patterns": [
{
"match": "(?i)text|long|double|date|boolean|categorical|loop|info|define|compound|block|page",
"name": "keyword.source.js",
"comment": "Question type"
},
{
"match": "\\b(?i)(fields|use|db)\\b",
"name": "storage.type.mdd-metadata"
},
{
"match": "\\b(?i)(ran|randomize|rot|rotate|rev|reverse|asc|ascending|desc|descending|fix|namespace|exclusive|expression|other|column|row|sublist|expand|grid|defaultanswer)\\b",
"name": "storage.type.js"
},
{
"match": "\\b(?i)(metadata|end metadata)\\b",
"name": "storage.type.js"
},
{
"match": "\\{|\\}",
"name": "meta.brace.curly.js"
},
{
"match": "\\(|\\)",
"name": "meta.brace.round.js"
},
{
"match": "\\[|\\]",
"name": "meta.brace.square.js"
},
{
"begin": "\"",
"beginCaptures": {
"0": {
"name": "punctuation.definition.string.begin.mdd-metadata"
}
},
"end": "\"",
"endCaptures": {
"0": {
"name": "punctuation.definition.string.end.mdd-metadata"
}
},
"name": "string.quoted.double.js",
"patterns": [
{
"match": "\\\\(x\\h{2}|[0-2][0-7]{,2}|3[0-6][0-7]|37[0-7]?|[4-7][0-7]?|.)",
"name": "constant.character.escape.mdd-metadata"
}
]
}
],
"uuid": "110bbd48-3940-4f28-aefd-0a5270328360"
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>comment</key>
<string>SPSS Dimensions Metadata Syntax: versio 0.1.0</string>
<key>fileTypes</key>
<array>
<string>mdd-metadata</string>
</array>
<key>name</key>
<string>SPSS Metadata</string>
<key>patterns</key>
<array>
<dict>
<key>comment</key>
<string>Question type</string>
<key>match</key>
<string>(?i)text|long|double|date|boolean|categorical|loop|info|define|compound|block|page</string>
<key>name</key>
<string>keyword.source.js</string>
</dict>
<dict>
<key>match</key>
<string>\b(?i)(fields|use|db)\b</string>
<key>name</key>
<string>storage.type.mdd-metadata</string>
</dict>
<dict>
<key>match</key>
<string>\b(?i)(ran|randomize|rot|rotate|rev|reverse|asc|ascending|desc|descending|fix|namespace|exclusive|expression|other|column|row|sublist|expand|grid|defaultanswer)\b</string>
<key>name</key>
<string>storage.type.js</string>
</dict>
<dict>
<key>match</key>
<string>\b(?i)(metadata|end metadata)\b</string>
<key>name</key>
<string>storage.type.js</string>
</dict>
<dict>
<key>match</key>
<string>\{|\}</string>
<key>name</key>
<string>meta.brace.curly.js</string>
</dict>
<dict>
<key>match</key>
<string>\(|\)</string>
<key>name</key>
<string>meta.brace.round.js</string>
</dict>
<dict>
<key>match</key>
<string>\[|\]</string>
<key>name</key>
<string>meta.brace.square.js</string>
</dict>
<dict>
<key>begin</key>
<string>"</string>
<key>beginCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.begin.mdd-metadata</string>
</dict>
</dict>
<key>end</key>
<string>"</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.definition.string.end.mdd-metadata</string>
</dict>
</dict>
<key>name</key>
<string>string.quoted.double.js</string>
<key>patterns</key>
<array>
<dict>
<key>match</key>
<string>\\(x\h{2}|[0-2][0-7]{,2}|3[0-6][0-7]|37[0-7]?|[4-7][0-7]?|.)</string>
<key>name</key>
<string>constant.character.escape.mdd-metadata</string>
</dict>
</array>
</dict>
</array>
<key>scopeName</key>
<string>source.mdd-metadata</string>
<key>uuid</key>
<string>110bbd48-3940-4f28-aefd-0a5270328360</string>
</dict>
</plist>
{
"cmd": ["mrScriptCL.exe", "\"{path_to_mrs_validator}/ProjectValidator.mrs\"", "/a:mddpath=$file"],
"selector": ["source.mdd.metadata"]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment