Have an idea?

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

Perl - setvalue based on string

Ok, so I have the following code

[% Begin Unverified Perl
# Begin by calculating the source in a numeric method

if (GETVALUE("USERID")    ==    "cardBraile")    {
        SETVALUE("source",2); # cardBraile
    }
    elsif (GETVALUE("USERID")    ==    "stopSign")    {
            SETVALUE("source",3); # stopSign
        }
    elsif (GETVALUE("USERID")    ==    "smsAlert")    {
            SETVALUE("source",4); # smsAlert
        }
    elsif (GETVALUE("USERID")    ==    "emailAlert")    {
            SETVALUE("source",5); # emailAlert
        }
    elsif (GETVALUE("USERID")    ==    "stWebsite")    {
            SETVALUE("source",6); # stWebsite
        }
    elsif (GETVALUE("USERID")    ==    "employerOrca")    {
            SETVALUE("source",7); # employerOrca
        }
    elsif (GETVALUE("USERID")    ==    "registeredOrca")    {
            SETVALUE("source",8); # registeredOrca
        }
    elsif (GETVALUE("USERID")    ==    "liftOrca")    {
            SETVALUE("source",9); # liftOrca
        }
    else{
        SETVALUE("source",1); # those who come in from intercept or from the regular/low vision survey response cards
        }

# now, categorizing into incentiveCategories

if (GETVALUE("source")    >= 3    &&
    GETVALUE("source")    <= 9)    {    
        SETVALUE("incentiveCategory",2); # if anything other than intercept, survey response card, braile card then set source = 2 which is drawing
    }
else    {
    SETVALUE("incentiveCategory",1); # the only other ways to enter the survey are through dynamic userid (intercept or survey response card)  or braile survey response card
    }


End Unverified %]


i know it is something simple, but I'm missing it.  No matter what it sets the value of 'source' as 2, subsequently setting the value of incentiveCategory as 1.

can you help me figure out what typo I made (it's late and my eyes are tired)?
asked Sep 30 by Nwiggin Bronze (1,725 points)

1 Answer

+1 vote
 
Best answer
Try changing your "==" to "eq" in your script when comparing strings / text.

That should work.
answered Oct 1 by Paul Moon Platinum (94,725 points)
selected Oct 1 by Nwiggin
Uuuggghhj...i knew that... Thanks Paul.
We're all guilty of that syntax issue aren't we.
...