[ic] Safe Syntax - Routine

Ed LaFrance edl@newmediaems.com
Fri, 08 Dec 2000 08:56:00 -0800


At 05:19 PM 12/7/00 -0700, you wrote:
>Dear List,
>
>I have a [perl] routine that I was using in MV 3.14-5, but it generates
>errors in Interchange 4.6.0.
>Does anyone know why this isn't working, or how to get it working?
>
>Thanks
>
>Russ
>
>
>This is the routine, in the basket page:
>
>[perl arg=scratch interpolate=1]
>my $numoff;
>my $totalbps = [calc]$totalbps[/calc];
>if ($totalbps <= 2) { $numoff = 0; }
>elsif (($totalbps >= 3) && ($totalbps <=9)) { $numoff = 1.96; }
>elsif ($totalbps >= 10) { $numoff = 2.46; }
>$discount_amount = $totalbps * $numoff;
>$Safe{'scratch'}->{'discount_amount'} = $discount_amount;
>$Safe{'scratch'}->{'numoff'} = $numoff;
>return '';
>[/perl]
>
>
>Here's my error entry:
>
>63.30.86.223 YeF5fEhT:63.30.86.47 - [07/December/2000:17:16:10 -0800] kh
>/store/
>kh/ord/basket.html Safe: syntax error at (eval 207) line 3, at EOF
> >
> >
> > my $numoff;
> > my $totalbps = ;
> > if ($totalbps <= 2) { $numoff = 0; }
> > elsif (($totalbps >= 3) && ($totalbps <=9)) { $numoff = 1.96; }
> > elsif ($totalbps >= 10) { $numoff = 2.46; }
> > $discount_amount = $totalbps * $numoff;
> > $Safe{'scratch'}->{'discount_amount'} = $discount_amount;
> > $Safe{'scratch'}->{'numoff'} = $numoff;
> > return '';
> >

Russ -

I was under the impression that [calc] would not work inside of [perl], but 
you say it worked before...  In any case, the above error message shows 
that [calc]$totalbps[/calc] is evaluating to null in your [perl] code - 
what is $totalbps and where is it assigned a value?  Perhaps assign it to a 
scratch variable just before the [perl]

[seti totalbps][calc]$totalbps[/calc][/seti]

... then put [scratch totalbps] on the page and pull it up in the browser - 
what do you see?  in the [perl] block you could do:

my $totalbps = '[scratch totalbps]' || '0';

...and see of that changes/eliminates the error messages.

- Ed L.



 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
New Media E.M.S.               Software Solutions for Business
463 Main St., Suite D          edl@newmediaems.com
Placerville, CA  95667         http://www.newmediaems.com
(530) 622-9421                 (530) 622-9426 Fax
(866) 519-4680 Toll-Free
 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>