Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

How to set a question into a ES string parameter

More
2 days 3 hours ago #274265 by orvil
Please help us help you and fill where relevant:
Your LimeSurvey version: 6.17
Own server or LimeSurvey hosting: own
Survey theme/template: default
==================
Hi,
is there a way to pass a string contaning a questions answer to an ES function without using join()? Something like string concatenation in php "Hello $name!"

like this, where Q007 is a question of type Equation:
    {someESfunction(param1, "Your result is: Q007 points.")}
instead of  
    {someESfunction(param1, join("Your result is: ", Q007, " points."))}

Thanks in advance!

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

Please Log in to join the conversation.

More
2 days 2 hours ago #274270 by Joffm
Hi,
of course you can use the "+" operator
"Your result is: "+Q007+" points."

But as you see in the manual

For consistency between JavaScript and PHP, the plus operator (+) does addition if both operands are numeric, but does concatenation if both parts are non-numeric strings. However, we recommend using the "join()" function for concatenation, as that makes your intent more clear. It also avoids unexpected results if you were expecting strings but got numbers instead (or vice versa).

Anyway: What's the reason for this?
As I understand you are going to develop a new function with two parameters, the "param1" and this text?

Joffm

Volunteers are not paid.
Not because they are worthless, but because they are priceless

Please Log in to join the conversation.

More
2 days 1 hour ago #274272 by orvil
Thanks 4 your reply!
The only reason for my question is a better readability of the ES. Cause I created an own ES function via plugin and the parameter (holding a query for a preset datatable) may become a little long. So readability would help :)

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

Please Log in to join the conversation.

Moderators: tpartnerholch

Lime-years ahead

Online-surveys for every purse and purpose