[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: Need help: checkout.html (II)
****** message to minivend-users from Frank Miedreich <miedreich@acm.org> ******
>****** message to minivend-users from Oliver Schade
><schade@outsource.de> ******
>
>
>Hi again,
>
>On Fri, 5 Mar 1999, minivend-users wrote:
>> Date: Fri, 5 Mar 1999 14:52:13 +0100
>> From: Frank Miedreich <miedreich@acm.org>
>> Subject: Re: Need help: Adjusting checkout.html
>
>[Customising checkout.html]
>
>> UserTag vat hasEndTag 1
>> UserTag vat Interpolate 1
>> UserTag vat Routine <<EOF
>> sub {
>> my ($a) = @_;
>> my $out ='';
>> my $vat = $a-$a/1.16;
>> $out .= '[currency]';
>> $out .= "$a";
>> $out .= '[/currency]';
>> return $out;
>> }
>> EOF
>>
>> and call with:
>> [vat][subtotal noformat=1][/vat]
>
>This even does not work :-(( Well, the facts:
>
> [vat][subtotal noformat=1][/vat]
>
>works and gives a number without any currency symbols.
>
> UserTag Routine sub { my ($a) = @_; return ($a); }
>
>works and returns just this unformatted number.
>
> UserTag Routine sub { my ($a) = @_; return ($a/100); }
>
>returns in every case 0.
>
> UserTag Routine sub { my ($a) = @_; return ($a-$a/1.16); }
>
>returns in every case 0.
>
> UserTag Routine sub { my ($a) = @_; local($b) = $a+100; return $b; }
>
>returns 100 (*argh*).
>
>Disabling UserTag Interpolate 1 has no effect. Is seems, that any arithmetic
>sets $a to zero... :-((( Any more ideas, please?
>
>Thanks for all other hints, most of them are working (expect this tricky one).
>
The cause for the problem is, the stuff between vat /vat is transmitted as
a string literal, thus $a becomes the string '[subtotal noformat=1]', which
yields 0 in an arithmatic expression.
The trick is to do [vat interpolate=1], which will enforce interpolation of
the containing stuff before the sub is executed.
Also fix the stupid bug in my code:
replace: my $vat = $a-$a/1.16;
with: $a = $a-$a/1.16;
as even the
The Interpolate = 1 will do the interpolation of the resulting string, so
you will get a properly formatted value.
--
Frank Miedreich
Max-Planck-Institut fuer psychologische Forschung
-
To unsubscribe from the list, DO NOT REPLY to this message. Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list