Post by Denis Melnikov4GL 7.32.UC2
Solaris 2.6
4GL must compare NULL to any not-NULL value as FALSE.
No. Except in the context of IS [NOT] NULL, NULL compared with anything,
including another null, is unknown. Since unknown is not TRUE, the IF
condition fails and the ELSE clause is taken.
And it acts this way... sometimes.
Post by Denis MelnikovDEFINE m_inv_amt DECIMAL(12,2)
FUNCTION AmtUsed()
IF m_inv_amt != 0 THEN
RETURN true
ELSE
RETURN false
END IF
END FUNCTION
<<<<<<<<<<<<<<<<<<
When m_inv_amt is NULL, AmtUsed() returns FALSE at one moment,
and TRUE at another. And the FALSE/TRUE sequence doesn't
change from run to run.
The function should always return FALSE when given NULL as an argument. The
condition compares NULL with something, which is unknown, and unknown is not
true, so the ELSE clause should *always* be chosen when the argument is
NULL.
If you can demonstrate that iteratively calling the function with a NULL
does indeed sometimes return true and sometimes returns false, then you have
a bug. I have my doubts about that - but if you can demonstrate the problem,
you have found a bug.
Is it a known bug or a new feature?
Now, I notice that in fact you are not passing m_inv_amt as an argument; it
is a global variable. All of a sudden, there are other mechanisms available
for producing indeterminate behaviour. Basically, anything that could be
modifying the global variable could be triggering the problem. And
'anything' could include accidental buffer overflows in some shape or form.
How do you know that m_inv_amt is always NULL before calling the function?
This is a case where there is precious little obvious advantage to using a
global and some obvious advantages to using a parameter.
To instrument, add an simple IF statement to the function:
IF m_inv_amt IS NULL THEN DISPLAY "m_inv_amt IS NULL" ELSE DISPLAY
"m_inv_amt IS NOT NULL" END IF
Or, if you have an error log open, log the message to the log.
Also track the return values - probably by modifying the main IF clause.
Keep track of whether there are any cases where minv_amt is null and you get
a true return from the function. In all honesty, I don't expect you to find
any, but show the demo code and the log and we can see what it takes to
reproduce it.
--
Jonathan Leffler #include <disclaimer.h>
Email: ***@earthlink.net, ***@us.ibm.com
Guardian of DBD::Informix v2005.02 -- http://dbi.perl.org/
sending to informix-list