[ic] Safe Syntax - Routine

Hans-Joachim Leidinger hans-joachim.leidinger@home.gelsen-net.de
Fri, 08 Dec 2000 21:43:05 +0100


Ed LaFrance wrote:
> 
> 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.

Or

my $totalbps = $Safe{'scratch'}->{'totalbps'} || '0';

Joachim

-- 
-------------Hans-Joachim Leidinger---------------------