Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Add Text in Perl-Code

Where is my mistake? I need the € sign in the second case additionally.

[% Begin Unverified Perl
if (LISTHASPARENTMEMBER("Randomization",4)) {
    return ACBCWINNERLABEL("ACBCLI", 5);
}
return (GETVALUE("VWDLI_r3_c1")&"€");
End Unverified %]


That code doesn't work - how should I change the inclusion of €

Thanks!
asked Jan 18, 2022 by Honeybadger Bronze (890 points)

1 Answer

0 votes
Try replacing with .€ or .€ where it says &”€”.

Special characters in Perl like this can be replaced by their entity names or entity numbers.

Let me know how you go.

I may have the syntax out slightly. I can check when I get back from the beach.
answered Jan 18, 2022 by Paul Moon Platinum (101,405 points)
First of all thanks for your engagement. But it doesn't work. I have tried the following two codes:


[% Begin Unverified Perl
if (LISTHASPARENTMEMBER("Randomization",4)) {
    return ACBCWINNERLABEL("ACBCLI", 5);
}
return (GETVALUE("VWDLI_r3_c1").€);
End Unverified %]



[% Begin Unverified Perl
if (LISTHASPARENTMEMBER("Randomization",4)) {
    return ACBCWINNERLABEL("ACBCLI", 5);
}
return (GETVALUE("VWDLI_r3_c1").€);
End Unverified %]
I've managed to take a closer look now that I'm back from the beach. A little to tidy up.

We need to add double quotes around € and €.

You also need to insert your else and {} for the 2nd condition.

See my example below which works well ...
[% Begin Unverified Perl
if (VALUE("Q1")==1) 
    {return VALUE("Q1");}

else
 {return (VALUE("Q1")."€")};
End Unverified %]

Just change your condition in the IF statement and what you need to return and this should work nicely for you.
It works perfectly! thank you! :)
Great to hear mate.

If you need to display special characters (like dollar signs or euro symbols) within Perl script, then do a Google search on entity names and you will see the entity names and numbers to use within your Perl script.
Just another little tip to add as another option in this type of scenario.  You can use \ in front of a special character like a monetary symbol in a Perl return expression instead of the html code.  So, to display '€100' you can show it as [% Begin Unverified Perl
{
    return "\€100";
}
End Unverified %]

This way you don't have to look up the corresponding code.
Nice, thanks for additional information.
Nice one Jay. I reckon I've been told this before and it slipped my mind. But thanks mate for the helpful tip as always. Always trust advice from the wild wild west.
Paul, lol.  Yeah I tend to go with that shortcut a lot, especially if I have a study returning monetary amounts for several countries.
...