If the main purpose is to make sure that neither value is zero, instead of this :
IF P.MOR <> 0 AND P.MOB <> 0 THEN...
wouldn't this work just as well and be more simple, shorter, and faster if it was in a loop?
IF P.MOR * P.MOB THEN...
Just wondering...
It would, with one little -- but vitally important - caveat attached:
BE ALERT OF OVERFLOW VALUES!! THEY COULD GIVE FALSE RESULTS!!For example, let's just use an _UNSIGNED _BYTE as an example.
_DEFINE A TO Z AS _UNSIGNED _BYTE
A = 16
B = 16
IF A * B THEN....
Now, A * B = 256. It's JUST the perfect number that if our IF is bound by unsigned bytes, that it's going to overflow to become 0. All at once, those two TRUE statements just became an unintended FALSE statement.
Now, with that caveat said, I'd also like to say, "I don't have a clue what variable TYPE an IF statement actually uses for internal calculations." When we do A * B, is the intermittent result that we compare against 0 an _UNSIGNED _BYTE like the two initial variable types? Is it a LONG? A _FLOAT??
Honestly, I don't have a clue. I know I've dug into the question before in the past, but my poor memory can't supply the answer for me at this exact moment. All I'm certain of is that IF A * B ends up being the *exact* limit of that variable type + 1, it's going to overflow to become 0. In 99.998% of all cases, it may be a completely moot issue as that internal value is a LONG and you're multiplying two BYTES together -- which will NEVER overflow -- but I'd prefer not to take a chance on it. When that rare 0.002% glitch shows up where my code DOES multiple two values together that perfectly hit the overflow value back to 0, I know I'd have a three day marathon of debugging and pulling my poor hair out, looking for the issue.
IF A <> 0 AND B <> 0 THEN.... <--- Never any issues with this, and it's actually quite readable and easy to understand.
IF A * B THEN.... <--- This might run faster and be shorter code, but there's always the chance that SOMETIME, it's going to overflow. And, I know myself -- when it does, something like this would drive me absolutely insane trying to find it and debug it. Because, after all, it works perfectly well all the rest of the time!