Survey Solutions

Support portal and knowledge base

Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Correct use of `?` conditional expression operator

Peter Ellis Mar 07, 2018 02:40PM EST



I am trying to define a variable with the help of the ? conditional expression operator described at http://support.mysurvey.solutions/customer/en/portal/articles/2537453-syntax-guide-operators.

My minimal example is a variable of Long integer variable type defined by the expression

(10 < 2)? 1:4

which I have copied straight from the helpfile, just replacing a and b with 1 and 4. I would have thought this would place the value 4 in the variable (because 10 is not less than 2, so it returns the expression to the right of the colon). But instead I get WB0027 "Expression has a syntax error". What am I doing wrong?

2 Community Answers

Best Answer
Sergiy Radyakin Mar 07, 2018 03:55PM EST

Peter,

no this is not a problem: The questionnaire compiles even if you set the variable as type Long, since, as you wrote indeed the result is of integer type.
The problem is likely not in the definition of the variable, but perhaps related to it’s use later in the questionnaire.

Best, Sergiy.

View in conversation


Up 0 rated Down
Peter Ellis Mar 07, 2018 02:41PM EST
OK, I think I solved this myself, just by defining the variable as a Double instead of a Long integer. This seems a little odd to me as both expressions return integers, but perhaps was the solution.
Up 1 rated Down
Sergiy Radyakin Best Answer Mar 07, 2018 03:55PM EST Survey Solutions Agent

Peter,

no this is not a problem: The questionnaire compiles even if you set the variable as type Long, since, as you wrote indeed the result is of integer type.
The problem is likely not in the definition of the variable, but perhaps related to it’s use later in the questionnaire.

Best, Sergiy.

This question has received the maximum number of answers.

support@mysurvey.solutions
http://assets2.desk.com/
false
desk
Loading
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
about
false
Invalid characters found
/customer/en/portal/articles/autocomplete?b_id=12728