Mailing List Archive

problem with perl
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
problem with perl [ In reply to ]
ACC&S wrote:

> $_= ($Safe{'scratch'}{'var2'} * $Safe{'scratch'}{'var1'}) ;

Ouch, thats got to hurt. :-)



--
____
\__/ 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
problem with perl [ In reply to ]
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
problem with perl [ In reply to ]
ACC&S wrote:

> some shocking code;

Any time your trying to write some perl stuff for minivend/interchange try
seeing if it will work in a proper perl program first.

so If i was writing the above I would have tested it with somethng like this...

------------------------------

#!/usr/bin/perl -w

use strict;

my %Scratch ;

$Scratch->{var1}= 2;
$Scratch->{var2}= 3;

print test();

sub test{

$_= $Scratch->{var1} * $Scratch->{var2};
return $_;

}

----------------------------

Save it in a file say test.pl and run it with "perl -c test.pl && perl test.pl"
and look at the debug info.
Once your sub routine is working at is a good bet that the algorithm will work
in minivend.

--
____
\__/ 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
problem with perl [ In reply to ]
Thanks for your help, I know it's very difficult !! ;o)
Sorry but your code... not good...
It's just a problem of decimal with scratch variable...
Sorry for my english...... :o((

----- Original Message -----
From: Murray Gibbins <Murray@scotweb.ltd.uk>
To: <interchange-users@lists.akopia.com>
Sent: Thursday, January 18, 2001 5:54 PM
Subject: Re: [ic] problem with perl


> 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
>
> _______________________________________________
> Interchange-users mailing list
> Interchange-users@lists.akopia.com
> http://lists.akopia.com/mailman/listinfo/interchange-users
>
problem with perl [ In reply to ]
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
problem with perl [ In reply to ]
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
problem with perl [ In reply to ]
:o(( my result = Test and Out blanck, nothing, nada !!??


[seti tva][data table="tva" column="taux" key="[item-field Cat_tva]"][/seti]
[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]

tva : 0.196 ([scratch tva])
subtotalvar : 2500 ([scratch subtotalvar])
test : ([scratch test])
out : ([scratch out])



Thanks for your help


----- Original Message -----
From: Hans Joachim Leidinger <hans-joachim.leidinger@home.gelsen-net.de>
To: <interchange-users@lists.akopia.com>
Sent: Thursday, January 18, 2001 8:55 PM
Subject: Re: [ic] problem with perl


> 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
>
> _______________________________________________
> Interchange-users mailing list
> Interchange-users@lists.akopia.com
> http://lists.akopia.com/mailman/listinfo/interchange-users
>
problem with perl [ In reply to ]
ACC&S wrote:
>
> :o(( my result = Test and Out blanck, nothing, nada !!??
>
> [seti tva][data table="tva" column="taux" key="[item-field Cat_tva]"][/seti]
> [seti subtotalvar][item-subtotal noformat=1][/seti]
>
> [perl interpolate=1 arg='scratch values']
> my a$;
> my b$;

Ooops! It should be as
my $a;
my §b;

It was a typo! Sorry!

> $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]
>
> tva : 0.196 ([scratch tva])
> subtotalvar : 2500 ([scratch subtotalvar])
> test : ([scratch test])
> out : ([scratch out])
>
> Thanks for your help

Or try

[seti tva][data table="tva" column="taux" key="[item-field
Cat_tva]"][/seti]
[seti subtotalvar][item-subtotal noformat=1][/seti]

Test 1: [sratch tva]<BR>
Test 2: [sratch subtotalvar]<BR>

[perl interpolate=1 arg='scratch values']
my $a;
my $b;
my $c;
$a = $Safe{'scratch'}->{'tva'};
$b = $Safe{'scratch'}->{'subtotalvar'};
$c = $a * $b;
$Safe{'scratch'}->{'test'} = $a;
$Safe{'scratch'}->{'out'} = $b;
$Safe{'scratch'}->{'out2'} = $c;
return '';
[/perl]

tva : 0.196 ([scratch tva])<BR>
subtotalvar : 2500 ([scratch subtotalvar])<BR>
test : ([scratch test])<BR>
out : ([scratch out])<BR>
out2 : ([scratch out2])<BR>

Joachim

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