Syntax for if-statements: Is there a way to use a vector in if-statements

More
4 weeks 1 day ago #169201 by DVP17lemon
DVP17lemon created the topic: Syntax for if-statements: Is there a way to use a vector in if-statements
Hello, I am using a conjoint experiment with placeholders, that should print a yes/no if they match a variable that was assigned to 256 random combinations.


Now a segment of the placeholder looks like this:

{if(RANDOM == 3 or RANDOM == 4 or RANDOM == 7 or RANDOM == 8 or RANDOM == 11 or RANDOM == 12 or RANDOM == 15 or RANDOM == 16 or RANDOM == 19 or RANDOM == 20 or RANDOM == 23 or RANDOM == 24 or RANDOM == 27 or RANDOM == 28 or RANDOM == 31 or RANDOM == 32 or RANDOM == 35 or RANDOM == 36 or RANDOM == 39 or RANDOM == 40 or RANDOM == 43 or RANDOM == 44, 'Yes', 'No')}

Is there a way to use a vector like this:

if(RANDOM == (3,4,7,8), 'Yes', 'No') ?

Or a different operator like "in"?

Please Log in or Create an account to join the conversation.

More
3 weeks 6 days ago #169226 by tpartner
tpartner replied the topic: Syntax for if-statements: Is there a way to use a vector in if-statements
No, that is not available in Expression Manager.

Cheers,
Tony Partner
Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.

Please Log in or Create an account to join the conversation.

More
3 weeks 6 days ago #169232 by orvil
orvil replied the topic: Syntax for if-statements: Is there a way to use a vector in if-statements
Just another problem where an extendable EM could help!
Solved a similar problem by doing so - but have to maintain and re-edit em_core_helper.php after every update :(

Best regards/Beste Grüße,
O. Villani

Please Log in or Create an account to join the conversation.

More
3 weeks 6 days ago #169241 by holch
holch replied the topic: Syntax for if-statements: Is there a way to use a vector in if-statements
Tried to push it to the core?

I'm not a LimeSurvey GmbH member. I answer at the LimeSurvey forum in my spare time. No support via private message.
Some helpful links: Manual (EN) | Question Types | Workarounds

Please Log in or Create an account to join the conversation.

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!