The State Variable Editor provides a syntax checker that you run your script through to check for errors. To do so:
Click the Compile Script button below the Text Editor (UPDATED IN V4.0 button label updated in 4.0 from the previously misleading "compile script" label)
If you get a message box with a note about the syntax error.
Select OK to dismiss the message box.
Correct the mentioned syntax error.
Repeat the above steps until the process results in a message box that says "Script Compiled Successfully". Select OK to close the message box; then save the state variable.