Have an idea?

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

Trying to construct a list if greater than answer to prior question

if a respondent says they would be interested in upgrading their speed, we want to know what speed they'd like to upgrade to, but the list should only show speeds faster than they currently have. so basically if currentspeed=1, then the list should only show 2-9, if currentspeed=2 then the list should only show 3-9.

this is what i currently have written but its giving me error 132

Begin Unverified Perl
if(VALUE("CurrentSpeed")=1)
{REMOVE("SpeedList",1)}
elsif(VALUE("CurrentSpeed")=2)
{REMOVE("SpeedList",1,2)}
elsif(VALUE("CurrentSpeed")=3)
{REMOVE("SpeedList", 1, 3)}
elsif(VALUE("CurrentSpeed")=4)
{REMOVE("SpeedList", 1, 4)}
elsif(VALUE("CurrentSpeed")=5)
{REMOVE("SpeedList", 1, 5)}
elsif(VALUE("CurrentSpeed")=6)
{REMOVE("SpeedList", 1, 6)}
elsif(VALUE("CurrentSpeed")=7)
{REMOVE("SpeedList", 1, 7)}
elsif(VALUE("CurrentSpeed")=8)
{REMOVE("SpeedList", 1, 8)}
else("SpeedList")
End Unverified
asked Oct 23, 2019 by anonymous
Does setting your constructed list instructions to this satisfy your needs?

Add(SpeedList, CurrentSpeed + 1, 9)
Nice and simple, I love it!  I was focused more on the solution that was being used instead of simplifying it.
Thanks, Jay.  Good to have both bases covered.

1 Answer

0 votes
Two things I notice.  The first is adding a semicolon after each instruction.  The second is you have a final else statement with no instruction, just a list name.  I believe the below code should work.

ADD (Speedlist)
Begin Unverified Perl
if(VALUE("CurrentSpeed")=1)
{REMOVE("SpeedList",1);}
elsif(VALUE("CurrentSpeed")=2)
{REMOVE("SpeedList",1,2);}
elsif(VALUE("CurrentSpeed")=3)
{REMOVE("SpeedList", 1, 3);}
elsif(VALUE("CurrentSpeed")=4)
{REMOVE("SpeedList", 1, 4);}
elsif(VALUE("CurrentSpeed")=5)
{REMOVE("SpeedList", 1, 5);}
elsif(VALUE("CurrentSpeed")=6)
{REMOVE("SpeedList", 1, 6);}
elsif(VALUE("CurrentSpeed")=7)
{REMOVE("SpeedList", 1, 7);}
elsif(VALUE("CurrentSpeed")=8)
{REMOVE("SpeedList", 1, 8);}
End Unverified
answered Oct 23, 2019 by Jay Rutherford Gold (37,335 points)
...