MiniVend Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Re: Problems with discount formula



******    message to minivend-users from Massimo Ferrario <massimo@mail.inforeti.it>     ******

At 20.30 16/01/99 -0500, Mike Lerley wrote:
>
>I tested this extensively and determined that == was the operator of choice.
[...]
> If that was the case, however, all products would be
>returned discounted rather than NOT discounted, because the first return 
>statement would fail.  
>
>Joe Hourcle wrote:
[...]
>>
>> > [discount ALL_ITEMS]
>> >         return $s if "[item-field category]" == "Cold Bay Seafood";
>> >         return 17*$q*5 if $totalq{"Hanson Bros."} >= 10;
>> >         return (27-$q)*5*$q;
>> > [/discount]
>>
>> as I think [discount] passes everything to perl, you may want to try using
>> 'eq' inplace of '==' as it's a string comparison, not a number comparison.

Well, Perl has a rather 'strange' behaviour in such thing (well, perhaps
it's only looking 'strange' to me: it is well documented): 
when you compare two strings as numbers, the strings will be converted to
numbers before being compared. As stated in "Programming Perl" 'any
non-numeric string is numerically equal to zero'.
So in your case the first if statement will succeed (it looks like return
$s if 0 == 0; to Perl) and no product will be discounted.

Hope this helps.

Ciao


---------------------------------------
Massimo Ferrario
Inforeti snc
via Pellizzo, 39 - 35100 Padova (Italy)
http://www.inforeti.it
-
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


Search for: Match: Format: Sort by: