[ic] problem with perl

Murray Gibbins Murray@scotweb.ltd.uk
Thu, 18 Jan 2001 16:54:01 +0000


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.

-- 
  ____
  \__/    Murray Gibbins             murray@scotweb.ltd.uk
  /  \    Programmer
_ \__/ _  ================================================
\\ || //  Scotweb Limited,             info@scotweb.ltd.uk
 \\||//   13a Albert Terrace,    http://www.scotweb.ltd.uk
  \||/    Edinburgh EH10 5EA   Tel: +44 (0)  131 270 82 33
   ||     Scotland. Europe.    Fax: +44 (0) 7020  93 49 04