Understanding Script Control Syntax
The following topics address the syntax for script controls.
Topics:
Understanding Case Sensitivity
The master scripts and underlying JavaScript require case sensitivity for function calls or when referring to a variable. For example in Script Control Structure (if/then/else) you see the function addFee called in both the then and else action. If you write the same script control but call the function AddFee, the script returns an error that the function AddFee does not exist. The script considers addFee and AddFee two different function names.
Understanding Variable and Function Names
Variables and function names in the master scripts follow the camelCase practice. For example totalSquareFeet, taxiNumber, addFee(), etc. Always be aware of case sensitivity as it many times could be the culprit of causing script errors.
Understanding Curly Brackets
We already saw the usage of the caret (^) to form conditional statements, another master script specific syntax is the usage of curly brackets { }. When a user triggers an event, Civic Platform calls the associated master script. Before EMSE evaluates the first line of script controls, the master script does some pre-work to initialize and set the value of several global and event-specific variables that the script controls can reference. Some of this pre-work loads application information, task information, and parcel attributes into individual variables. The script control encloses each of these variables between two curly brackets (Script Control Structure (if/then/else)). For example, {Acres Disturbed} in the script control condition indicates an application specific Information field.
Understanding Argument Types
Always enclose strings in double quotes. For example:
the criteria -- {Land Use} == “Farming”
setting the value of a variable -- layerName = “Zoning”
a function call that accepts string parameters addFee(“AppFee”,”BLD_11”,”FINAL”,1,”Y”)
Do not enclose numeric fields in double quotes.
Script controls must be valid JavaScript. If a script control deviates from JavaScript syntax, outside of that which is unique to the master scripts, syntax errors occur.