Examples of Syntax and Behavior Differences
| JScript.NET code example | JavaScript code example | Comments |
DeviceType.toString() == "Desktop"
DeviceType == "Desktop"
|
|
toString() for enums returns it's integer value, not name. |
f('q1').values().toString() == "1, 2"
^f('q1').values()^ returns "1,2"
|
f('q1').values().toString() == "System.Object[]"^f('q1').values()^ returns "System.Object[]"
|
SurveyArrayList no longer exists, so standard .NET array is used. String representation of standard .NET types cannot be changed. |
f('q1')['1']f('q1')('1')f('q1').get_Item('1')Request.Form['q1']Request.QueryString["test"]UserParameters[paramName]
|
|
item() instead of .NET indexer []. |
|
|
N/A | .NET CLR types not supported. |
var o : Date = new Date()
function ImagenesURL():String { return '' }
|
var o = new Date()
function ImagenesURL() { return '' }
|
No strict types declaration. |
|
|
|
|
GetCatiRespondentUrl(String questionId, params String[] @params) |
GetCatiRespondentUrl(String questionId
|
|
GetRespondentUrl(String questionId, params String[] params) |
GetRespondentUrl(String id)
|
|
UserParameters[paramName] |
UserParameters.item(paramName)
|
|
SetPanelistCredit(Int32 credit, String comment, String sectionId) |
SetPanelistCreditBySectionId(Int32 credit, String comment, String sectionId)
|
|
SetPanelistCredit(Int32 credit, String comment, Int32 panelistId) |
SetPanelistCreditByPanelistId(Int32 credit, String comment, Int32 panelistId)
|
|
SetPanelistCreditWithCustomVariables(Int32 credit, String comment, String sectionId, String[] fieldNames, String[] fieldValues) |
SetPanelistCreditWithCustomVariablesBySectionId(Int32 credit, String comment, String sectionId, String[] fieldNames, String[] fieldValues)
|
|
SetPanelistCreditWithCustomVariables(Int32 credit, String comment, Int32 panelistId, String[] fieldNames, String[] fieldValues) |
SetPanelistCreditWithCustomVariablesByPanelistId(Int32 credit, String comment, Int32 panelistId, String[] fieldNames, String[] fieldValues)
|
|
| N/A | Cookies | |
| N/A | CreateCookieObject(String name, String value)
|
|
IsNet(object quadIP, object quadNet, object quadMask) |
N/A |
| Jscript.NET | JavaScript | Comments | |
| Catching exceptions | { f('invalid-question-id') }
catch { } |
f('invalid-question-id') |
JavaScript engine invocation exception cannot be caught. |
For more examples, refer to the following articles:
Referencing the Elements of a Multi-Ranking, Open-Text List, Numeric List, or Grid
Additional Syntax and Behavior Differences
In Forsta scripting, arrays cannot be automatically converted to strings using the caret (^) operator.
This limitation affects functions such as domainValues(), domainLabels(), categories(), and categoryLabels(), which return arrays.
To use these functions within surveys, you must first convert the arrays to strings using the .toString() method.
For Example:
var valuesArray = domainValues();
var valuesString = valuesArray.toString();
Differences between Jscript.Net code and JavaScript code for Offline Mobile Apps (CAPI, AskMe):
| Jscript.NET code | JavaScript code | Comments | |
| Referencing a COMPOUND question code: |
f(‘Q1’)[‘2’] == ‘1’
f(‘Q1’)[‘2’].set(‘1’)
|
f(‘Q1’).item(‘2’) == ‘1’
f(‘Q1’).item(‘2’).set(‘1’)
|
Differences:item() instead of .NET indexer []
|
Numeric lists and use of .values()
|
SUM(f(‘Q1’))
SUM(f(‘Q1’).values())
|
SUM(f(‘Q1’).values()) |
Differences: .values() now required |
| Creating a set object | var s = new Set() | var s = set() | |
| Creating an array | var a = new Array(1,2,3,9,10); | var a = ['1','2','3','9','10']; |