I know it's hard to beleive. I have spent all day debugging some code and have finnaly found the culprit. This is the offending code:
/* ========================================================================== LoadPhoneLine ==========================================================================*/ METHOD PUBLIC LOGICAL LoadPhoneLine(p_PhoneLineGUID AS CHAR): DEF BUFFER PhoneLine FOR PhoneLine. FIND PhoneLine WHERE PhoneLine.PhoneLineGUID EQ p_PhoneLineGUID NO-LOCK NO-ERROR. IF NOT AVAIL PhoneLine THEN DO: ASSIGN THIS-OBJECT:PhoneLineGUID = "" THIS-OBJECT:PhoneNumber = "". END. ELSE DO: ASSIGN THIS-OBJECT:PhoneLineGUID = p_PhoneLineGUID THIS-OBJECT:PhoneNumber = PhoneLine.PhoneNumber. END. RETURN AVAIL PhoneLine. END METHOD.
METHOD PUBLIC CHAR GetPhoneLineConfig (p_PhoneLineGUID AS CHAR): DEF BUFFER PhoneLine FOR PhoneLine. IF NOT THIS-OBJECT:LoadPhoneLine(p_PhoneLineGUID) THEN . DO: MessageManager:LogError(SUBSTITUTE("No Phoneline [&1] Exists",p_PhoneLineGUID)). RETURN "". END.
RETURN "stuff".
END METHOD.
The method GetPhoneLineConfig always returns "" . However, if I change it to read
METHOD PUBLIC CHAR GetPhoneLineConfig (p_PhoneLineGUID AS CHAR): DEF BUFFER PhoneLine FOR PhoneLine.
DEF VAR Check AS LOGICAL NO-UNDO.
ASSIGN Check = THIS-OBJECT:LoadPhoneLine(p_PhoneLineGUID).
IF NOT Check THEN DO: MessageManager:LogError(SUBSTITUTE("No Phoneline [&1] Exists",p_PhoneLineGUID)). RETURN "". END.
RETURN "stuff".
then "stuff" is returned.
As mentioned, I spent most of the afternoon finding this piece of code. I checked. I double-checked. However, no demo code I produced gave the same problem.
Can you spot the problem ?
(Hint. It's empty)
Can you spot the problem ?
(Hint. It's empty)
Ouch. Or should that be "d'oh". Or maybe, as my good friend Bill would say "out, damn'd spot!".
I really dislike these kinds of bugs, both for the time they take to find and for making me question my sanity (more than usual, I mean).
-- peter
Yet another good reason for putting the DO on the same line as the THEN .
I don't like the default formatting ^A^I in Architect, and I'd specifically like to change this behavior.