Jump to content

need If not help


au3scr
 Share

Recommended Posts

Need help with getting this if sentence working.

$current_title "Is text"

$modified = 0

;ATM If sentence have no effect, how i make that if sentence do action when string's 1-st symbol is not *? ($is_star)

Func do_Func ()

$is_star = StringLeft($current_title, 1)

If NOT $is_star = "*" Then

WinSetTitle($current_title,"","*"&$current_title)

$current_title = "*"&$current_title

$modified = 1

EndIf

EndFunc

Link to comment
Share on other sites

If NOT $is_star = "*" Then

should be

If $is_star <> "*" Then

Because I was bitten by this myself once I would add WHY:

Look in the help file under Operators at the Order of Operations.

NOT has an earlier place than variable assignment. In fact is comes first in the list.

So this code: If NOT $is_star = "*" Then

Is equivalent to this: If (NOT $is_star) = "*" Then

You could make it work with this: If NOT ($is_star = "*") Then

But the correct usage (as previously pointed out) is just: If $is_star <> "*" Then

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Because I was bitten by this myself once I would add WHY:

Look in the help file under Operators at the Order of Operations.

NOT has an earlier place than variable assignment. In fact is comes first in the list.

So this code: If NOT $is_star = "*" Then

Is equivalent to this: If (NOT $is_star) = "*" Then

You could make it work with this: If NOT ($is_star = "*") Then

But the correct usage (as previously pointed out) is just: If $is_star <> "*" Then

:)

And if you are "speed fan" you will use If $is_star <> "*" Then because it will return faster.

Or use Switch...Case...EndSwitch -that is the fastest way.

♡♡♡

.

eMyvnE

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