Have an idea?

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

Determine Next MaxDiff Quota - Syntax?

Solution: In addition to tripping myself up with orphaned parens trying to fix by assuming value resolution issues, the real issue for...

Log shows an error "Server Error: Unrecognized character \xC2 ".

... Is that there were hidden whitespaces in the code.  It was suggested that this happened as a result of copying the function from help.  

Original question follows...

I'm still relatively new to Sawtooth and definitely to Perl and first time poster.  I am just not spotting what is wrong with the Syntax... I think the logic is good...
I've commented out the lines that cause an error (assuming syntax issue?).  Log shows an error "Server Error: Unrecognized character \xC2 ".

FuncBenefit is a multi-select check box and that is the capitlization for it.
I am trying to test answers for items 1-8 and of those selections find the cell with most available items in a quota.

[%

 Begin Unverified Perl

#Does not like either line with if Nor QUOTACELLREMAINING

my $QuotaCount = 0;
my $QuotaReturn = 0;
my $i;

for($i = 1; $i<=8; $i++)
    {
        if (VALUE(("FuncBenefit_" . $i) == 1)
            {
            #if ($QuotaCount < QUOTACELLREMAINING (("FuncBenefitQuota", $i))    
                {
                $QuotaReturn = $i;
                      #$QuotaCount = QUOTACELLREMAINING (("FuncBenefitQuota", $i));
                }    
            }
    }


return "<input type='hidden' id='QuotaSel_A' name='QuotaSel_A' value=" . $QuotaReturn . ">";
 End Unverified

%]

asked Jun 17, 2013 by JasonC (255 points)
edited Jun 18, 2013 by JasonC

1 Answer

0 votes
Welcome to the forum! At first glance it looks like you have some extra/mismatched parentheses in your code. I would try changing

if (VALUE(("FuncBenefit_" . $i) == 1)
{
   #if ($QuotaCount < QUOTACELLREMAINING (("FuncBenefitQuota", $i))   
  {
    $QuotaReturn = $i;
    #$QuotaCount = QUOTACELLREMAINING (("FuncBenefitQuota", $i));
  }   
}


to

if (VALUE("FuncBenefit_" . $i) == 1)
{
  #if ($QuotaCount < QUOTACELLREMAINING ("FuncBenefitQuota", $i))   
  {
    $QuotaReturn = $i;
    #$QuotaCount = QUOTACELLREMAINING ("FuncBenefitQuota", $i);
  }   
}


and let me know if it continues to give you trouble.
answered Jun 17, 2013 by Jeff Forkner Bronze (2,875 points)
edited Jun 17, 2013 by Jeff Forkner
I find it odd the way it adds Parens and didn't realize I had not gotten the second one in...  So the First If works with my edit below but that leaves the other two lines giving me trouble.

[%

 Begin Unverified Perl

#Does not like either line with if Nor QUOTACELLREMAINING

my $QuotaCount = 0;
my $QuotaReturn = 0;
my $i;

for($i = 1; $i<=8; $i++)
    {
        if (VALUE(("FuncBenefit_" . $i)) == 1)
            {
            #if ($QuotaCount < QUOTACELLREMAINING ("FuncBenefitQuota", $i)
                {
                $QuotaReturn = $i;
                #$QuotaCount = QUOTACELLREMAINING ("FuncBenefitQuota", $i);
                }    
            }
    }


return "<input type='hidden' id='QuotaSel_A' name='QuotaSel_A' value=" . $QuotaReturn . ">";
 End Unverified

%]
...