Results 1 to 4 of 4

Thread: Greater than Less Than comparison not working

  1. #1
    Join Date
    Jan 2019
    Location
    Greenville, SC
    Posts
    2

    Default Greater than Less Than comparison not working

    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!)

  2. #2
    Join Date
    Oct 2000
    Location
    Willis Wharf, VA
    Posts
    1,769

    Default

    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!)

  3. #3
    Join Date
    Oct 2000
    Location
    Willis Wharf, VA
    Posts
    1,769

    Default

    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!)

  4. #4
    Join Date
    Oct 2000
    Location
    Willis Wharf, VA
    Posts
    1,769

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •