Have an idea?

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

Use variable with Hashes

So I have the following code that worksfine:
[code}
[%
Begin Unverified Perl

   
  
  my %ScoresLookup = ();
  
    %ScoresLookup = (
   
     'pgesac19-01' => 1,
     'pgesac19-02' => 2,
     'pgesac19-03' => 3,
     'pgesac19-04' => 4,
    'pgesac19-05' => 5,
    'pgesac19-06' => 6,
    'pgesac19-07' => 7,
    'pgesac19-08' => 8,
    'pgesac19-09' => 9,
    'pgesac19-10' => 10,
    'pgesac19-11' => 11,
    'pgesac19-12' => 12
    );
 

     return $ScoresLookup{'pgesac19-12'};


End Unverified
%]
[/code]

I'm trying to replace the return statement with:


     return $ScoresLookup{'.GETVALUE("studynum").'};



where studynum = "pgesac19-12"  but the code doesn't want to work.  Thoughts?

thanks!
Chris
asked Apr 5 by Chris Guth Bronze (780 points)

1 Answer

+2 votes
 
Best answer
Chris,

If I'm understanding correctly, you don't need the apostrophes or periods around your function call:

return $ScoresLookup{GETVALUE("studynum")};
answered Apr 5 by Zachary Platinum Sawtooth Software, Inc. (115,375 points)
selected Apr 5 by Chris Guth
Thank you Zachary!
...