Work (dull)
Nov. 19th, 2004 11:27 amSpent a day trying to track down a bug. The logic seemed flawless, so I was utterly baffled. In the end it turned out to be another vagary of the ColdFusion decision functions.
If you try to do an "IF" statement using a variable that does not exist - for example, IF myvar = "x"[1], it throws an error (eg "myvar is undefined"). However, if you try to perform a disjunctive ("or") IF statement using two different variables, and one of them does not exist - for example IF (myvar = "x") OR (myothervar = "x") where myvar is undefined and mothervar is defined, it processes as normal. It's like the processor can handle the idea of an undefined variable when only one of these statements must be true (and resolves it to FALSE), but not when it's the only statement there. Crazy.
I only uncovered this because somebody was working on the same page and the button I normally press - which populates the hidden fields - was disabled, so when I went through the process I had to enter the delivery date manually. "hr24" was neither "y" nor "n", so it failed the IF statement.
I don't know how clear that is, but trust me, it's at the same time aggravating and wonderfully relieving. It's not me! It's you! Let's just be friends.
UPDATE: Actually, no, it always resolves to FALSE in a disjunctional conditional statement with one undefined variable, even if one of the other statements resolves to TRUE. Feck. Still, at least I know what I'm working on now...
UPDATE UPDATE: Oh. No. Noooo. Actually the variable is defaulting to "" (empty string). That produces a few interesting results... right, let's default it to "N" and see how that works.
[1] Note that this is not valid coldfusion syntax, but for illustration purposes only.
If you try to do an "IF" statement using a variable that does not exist - for example, IF myvar = "x"[1], it throws an error (eg "myvar is undefined"). However, if you try to perform a disjunctive ("or") IF statement using two different variables, and one of them does not exist - for example IF (myvar = "x") OR (myothervar = "x") where myvar is undefined and mothervar is defined, it processes as normal. It's like the processor can handle the idea of an undefined variable when only one of these statements must be true (and resolves it to FALSE), but not when it's the only statement there. Crazy.
I only uncovered this because somebody was working on the same page and the button I normally press - which populates the hidden fields - was disabled, so when I went through the process I had to enter the delivery date manually. "hr24" was neither "y" nor "n", so it failed the IF statement.
I don't know how clear that is, but trust me, it's at the same time aggravating and wonderfully relieving. It's not me! It's you! Let's just be friends.
UPDATE: Actually, no, it always resolves to FALSE in a disjunctional conditional statement with one undefined variable, even if one of the other statements resolves to TRUE. Feck. Still, at least I know what I'm working on now...
UPDATE UPDATE: Oh. No. Noooo. Actually the variable is defaulting to "" (empty string). That produces a few interesting results... right, let's default it to "N" and see how that works.
[1] Note that this is not valid coldfusion syntax, but for illustration purposes only.
no subject
Date: 2004-11-19 04:14 am (UTC)Btw can I ask what the link to that PPG/Samurai Jack/Dexter's Lab fanfic anime you put up a while back was as I've lost it :).
no subject
Date: 2004-11-19 05:40 am (UTC)That said, it may well have been here somewhere. SJ, DL and PPG all have subsections in the Cartoons area. Knock yourself out.