[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
Re: [ic] Numeric comparison with IF
On Mon, May 28, 2001 at 11:59:46AM +0200, Vagel wrote:
> Hello everyone,
> Sorry to bother you with an IF problem again, but i really tried a lot before writing to you... :-\
>
> The problem that i have is with 'if' and numeric comparison in Interchange V4.6.1.
>
> After having searched in the mail list i used some examples that i found on string comparisons but this doesn't gives me the result that i'would like.
>
> With the following code i'm trying to compare 2 numeric fileds : 'price_retail' and 'price'. When 'price_retail' is greater than 'price', i would like to display a message.
> This comparison works with '=' but not with '>'...
>
> Can anyone give me some info on what i'm missing?
>
You should check and make sure that $price_ret and $price_to_pay actually do
contain numbers, if they contain anything else (including dollar signs) they
will get compared as strings, which will give you odd results. The reason it
works with '=', is that it is not a comparison operator, try with == and see
what happens.
> ----------------- start of snipped code ------------------
> [if explicit]
> [condition]
> $price_ret = '[value loop-price_retail]';
> $price_to_pay = '[value loop-price]';
> return 1 if $price_ret > $price_to_pay;
> return 0;
> [/condition]
> message to display
> [/if]
> ------------------ end of snipped code ------------------
>
> Thank you in advance
> Cheers
> Vagel
--
Red Hat E-Business Solutions Jason Kohles
11480 Sunset Hills Road Senior System Architect
Reston, VA 20190 jkohles@redhat.com