[ic] problem with perl

Hans Joachim Leidinger hans-joachim.leidinger@home.gelsen-net.de
Thu, 18 Jan 2001 20:55:43 +0100


Murray Gibbins wrote:
> 
> ACC&S wrote:
> >
> > hi,
> >
> > I don't know PERL language, could you help me :
> >
> > my scratch variable tva = .196  and [item-subtotal noformat=1] = 2500, then
> > my result is :
> > test : [scratch test] = 0
> > res : [scratch out] = 0
> >
> > if i put     $Safe{'scratch'}->{'var1'} = 196 / 1000 ; then my result is OK
> > test : [scratch test] = 0,196
> > res : [scratch out] = 490
> >
> > this is my code :
> > [perl interpolate=1 arg='scratch values']
> >          $Safe{'scratch'}->{'var1'} = '[scratch tva]';
> >          $Safe{'scratch'}->{'var2'} = '[item-subtotal noformat=1]';
> >          $_1 = $Safe{'scratch'}{'var1'};
> >          $_= ($Safe{'scratch'}{'var2'} * $Safe{'scratch'}{'var1'}) ;
> >          $Safe{'scratch'}{'test'} = $_1;
> >          $Safe{'scratch'}{'out'} = $_;
> >          return '';
> > [/perl]
> >
> > Could you help to do the same thing with [scratch tva]
> > thanks
> 
> ok try this
> 
> --------------------------
> 
> [set tmp_val][item-subtotal noformat=1][/set]
> [perl global=1]
> 
> 
>         ! exists $Scratch->{tmp_val} ? die "no tmp_val":1;
>         ! defined $Scratch->{tmp_val} ? die "no defined tmp_val":1;
> 
>         ! exists $Scratch->{tva} ? die "no tva":1;
>         ! defined $Scratch->{tva} ? die "no defined tva":1;
> 
> 
>         eval{$Scratch->{test} = $Scratch->{tva}  * $Scratch->{tmp_val} ;};
>         if($@){
>                 $Scratch->{test} = "Opps";
>         }
>         return ;
> [/per]
> Return value : '[scratch test]'
> 
> ---------------------------
> 
> It's must be fun tryng to use interchange without knowing perl ;-)
> 
> Remember perldoc is your friend.


Or try

[seti subtotalvar][item-subtotal noformat=1][/seti]
[perl interpolate=1 arg='scratch values']
          my a$;
          my b$;
          $Safe{'scratch'}->{'var1'} = $Safe{'scratch'}->{'tva'};
          $Safe{'scratch'}->{'var2'} =
$Safe{'scratch'}->{'subtotalvar'};
          $a = $Safe{'scratch'}->{'var1'};
          $b = ($Safe{'scratch'}->{'var2'} * $Safe{'scratch'}->{'var1'})
;
          $Safe{'scratch'}->{'test'} = $a;
          $Safe{'scratch'}->{'out'} = $b;
          return '';
[/perl]

A perl newbie too!

Joachim
-- 
-------------<FreeBsd>--------------------------------------------------
Hans-Joachim Leidinger  email: hans-joachim.leidinger@home.gelsen-net.de
                        FAX  : +49 0209-398265