J_Y_C Posted September 21, 2007 Share Posted September 21, 2007 So, I have a condition to test, that a pixel color is in a certain value range. When I use an "IF" statement to perform the test, it doesn't work, but if I use a switch statement, it does. Check it out: This works: $swVal = PixelGetColor($x, $y) Switch ($swVal) Case ($RED-100000) To ($RED+100000) $lineState[$LN - 1] = 2 Return True EndSwitchoÝ÷ Ù8b±Ú²z-jëh×6$swVal = PixelGetColor($x, $y) if ($swVal>($RED-100000)) then if ($swVal<($RED+100000)) then $lineState[$LN - 1] = 2 Return True endif endif It seems to me that these should test the same, but they don't. Any ideas on why this is? The code works with the Switch statement, but it seems wanky to me, and I want to understand _why_. Thoughts? Link to comment Share on other sites More sharing options...
Monamo Posted September 21, 2007 Share Posted September 21, 2007 (edited) So, I have a condition to test, that a pixel color is in a certain value range. When I use an "IF" statement to perform the test, it doesn't work, but if I use a switch statement, it does. Check it out: This works: $swVal = PixelGetColor($x, $y) Switch ($swVal) Case ($RED-100000) To ($RED+100000) $lineState[$LN - 1] = 2 Return True EndSwitchoÝ÷ Ù8b±Ú²z-jëh×6$swVal = PixelGetColor($x, $y) if ($swVal>($RED-100000)) then if ($swVal<($RED+100000)) then $lineState[$LN - 1] = 2 Return True endif endifoÝ÷ Øly鬶¶¶¬zÈhºWmzËmëæî¶Ø^ÉÚ'ßÛ@(y«(r¶¬ÄáyÊ{ +Ì"¶ay,"µÈlµ«^éínëb¶ÇÌL¢gÒ0j{m¢éÝz»-jwp$á¢è!¶Ïêº^²,Þsû)jì7=êáj+,¹ì"¶az«z{azØj[¬j¢Ö¥&§¡»º· «)jÖ ¹ë,²)Üz+wöÈî²×!yÉ"®ç¨¬V¥±êÞ²'±ì!Èr¢êܡץ¢,¶Þ~)Þzk¢øx÷+µë-jëh×6$swVal = PixelGetColor($x, $y) If $swVal > ($RED - 100000) Then If $swVal < ($RED + 100000) Then $lineState[$LN - 1] = 2 Return True EndIf EndIf Edit: The "enclosing" parentheses don't seem to be an issue with another test script I did, but again... I'm grasping here Edited September 21, 2007 by Monamo - MoChr(77)& Chr(97)& Chr(100)& Chr(101)& Chr(32)& Chr(121)& Chr(97)& Chr(32)& Chr(108)& Chr(111)& Chr(111)& Chr(107)-------I've told you 100,000 times not to exaggerate!-------Don't make me hit you with my cigarette hand...-------My scripts:Random Episode Selector, Keyboard MouseMover, CopyPath v2.1, SmartRename for XP,Window Tracer[sup]New![/sup] Link to comment Share on other sites More sharing options...
J_Y_C Posted September 21, 2007 Author Share Posted September 21, 2007 Gee, I found this problem yesterday, and now that I come back to it all 3 method work. woof. I need some rest, I guess. Sorry for wasting your time, I should have re-checked again today. Link to comment Share on other sites More sharing options...
weaponx Posted September 21, 2007 Share Posted September 21, 2007 Solution probably looked like: $swVal = PixelGetColor($x, $y) if ($swVal >= ($RED-100000) AND $swVal <= ($RED+100000)) then $lineState[$LN - 1] = 2 Return True endif Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now