Jump to content

I don't understand this...


J_Y_C
 Share

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...