PDA

View Full Version : Greater than Less Than comparison not working



GRG
04-05-2024, 09:07 PM
I'm about to pull my hair out. I've built a custom touch pad and have customized the Ztouch routine to my liking. I've had some instances where the touch wasn't reliable and the z-zero was set incorrectly (ultimately driving the tool into the table if I didn't notice). I've built in an extra touch action, the results recorded, and compared to an allowable amount of error (0.002") between the last two touches. If not, it should throw an error message.

Everything is working fine except my final > < comparisons. they work fine if I type in actual numbers in place of the variables but the first comparison constantly return a false positive if I use my &ZZeroPDif variable in the comparison. If I change it to "less than" it does not continue the IF statement so it considers it false (incorrectly) I've tried doing some math to the variable just prior to the statement to ensure that it's treating it as a number and that works fine. I have it give me a printout of all of the variables and they're all working and looking perfectly as anticipated. I just can't get this comparison to work correctly. What am I doing wrong?


IF &ZZeroPDif > 0.002 Then MSGBOX (WARNING! Z ZEROING ACCURACY QUESTIONABLE!, OKONLY, WARNING!)
IF &ZZeroPDif < -0.002 Then MSGBOX (WARNING! Z ZEROING ACCURACY QUESTIONABLE!, OKONLY, WARNING!)

bill.young
04-08-2024, 08:13 AM
This doesn't answer your <> question...we'll look into that...but try replacing your 2 tests with the command below that uses the ABS command to get the Absolute Value of your variable and see if that does what you want:

IF ABS(&ZZeroPDif) > 0.002 Then MSGBOX (WARNING! Z ZEROING ACCURACY QUESTIONABLE!, OKONLY, WARNING!)

bill.young
04-08-2024, 08:24 AM
I haven't tested all the different possibilities, but if you want to have two tests I think your original tests work if you put the variable name in (), like the example below. Not sure why yet.


&ZZeroPDif = -0.003


IF (&ZZeroPDif) < -0.002 Then MSGBOX (WARNING! Z ZEROING ACCURACY QUESTIONABLE!, OKONLY, WARNING!)

bill.young
04-08-2024, 11:19 AM
I think I figured it out. It appears that it's parsing the trailing "if" in your variable name as a second IF statement. Changing your variable name from "&ZZeroPDif" to "&ZZeroPDf" or "&ZZeroPDiff" or something that doesn't have an "if" at the end of the name seems to work in my tests.

GRG
05-02-2024, 08:58 AM
OHHHH!!! Cool. Thank you. I'll test that tonight

GRG
05-02-2024, 08:59 AM
OHHHH!!! Cool. Thank you. I'll test that tonight

GRG
05-02-2024, 08:40 PM
That fixed it. Thank you!