Can I shorten this code:
while (1) {
theVal == getKey(); //getKey() returns a keypad response
if (theVal == keyCancel) return;
if (theVal == keyOK) break;
} //wait for ok
To this, or is not doing the same thing?
while (theVal == getKey() != keyOK) {
if (theVal == keyCancel) return;
} //wait for ok
I guess my question is:
In the 2nd code, in the While statement, I'm setting 'theVal' to the result of getKey(), and also checking if it's the keyOK value, and if so then it'll exit the while statement. Am I correct on this, or not, or maybe this isn't a good idea?
The real question is why do you care? The second form, even if it works, is obtuse, and hard to understand. It will certainly not save any memory space, so why write code that is harder to understand (not that the first form is all that great either...)?
Regards,
Ray L.
Also, you have the code, why not test it and answer your own question? My guess is, as Delta_G pointed out, there are likely semantic errors in the code.