Jump to content

No less than and no greater than (number)


kjpolker
 Share

Recommended Posts

Hello,

I have been digging through the help file and I can't find anything related to what I want.

I have in my code:

$i = 255

;blah blah

Func item1()
    WinSetTrans($hWnd, "", $i)
    $i -= 51
EndFunc

The point is to cycle through a new transparency with each call of the function. However, I need to set limits on $i to never be less than 0 or greater than 255. How is this achieved?

I am sure it's easy but I just don't see anything on it.

Edited by kjpolker
Link to comment
Share on other sites

Thank you! I didn't catch that. Final code works fine for what I am doing.

$i = 255

;Blah blah

Func Transparency1()
    If $i <= 255 And $i > 0 Then
    $i -= 51
    EndIf
    WinSetTrans($hWnd, "", $i)
EndFunc

Func Transparency2()
    If $i < 255 And $i >= 0 Then
    $i += 51
    EndIf
    WinSetTrans($hWnd, "", $i)
EndFunc
Edited by kjpolker
Link to comment
Share on other sites

Thinks that most of had made that mistake once  :)

Glad it worked :)

Another way it could be done is using switch

$i = 255

;Blah blah

Func Transparency1()
    Switch $i
    case 1 to 255
    WinSetTrans($hWnd, "", $i)
    Endswitch
EndFunc

Func Transparency2()
    WinSetTrans($hWnd, "", $i)
    If $i < 255 And $i >= 0 Then $i += 51
EndFunc

Cheers

/Rex

 

Edited by Rex
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...