magace

Please help using "or" in a if statement

4 posts in this topic

#1 ·  Posted

Hello I am detecting the fist 3 characters of a string and I want the script to do something if they match.  This works

Local $smidds = StringMid($readsn,1,3)
ToolTip($smidds,0,0)
If $smidds = "CN0" Then
;do whatever
EndIf

However when I try this it detects every 3 character string and tries to "do whatever".  Not just the CN0, PH0, MY0

Local $smidds = StringMid($readsn,1,3)
ToolTip($smidds,0,0)
If $smidds = "CN0" or "MY0" or "PH0" Then
;do whatever
EndIf

Any help?  And thanks for all the help over the years autoit community!

Share this post


Link to post
Share on other sites



#2 ·  Posted

Try If $smidds = "CN0" or $smidds = "MY0" or $smidds = "PH0" Then

Share this post


Link to post
Share on other sites

#3 ·  Posted

Thanks!  That worked.

Share this post


Link to post
Share on other sites

#4 ·  Posted

3 hours ago, magace said:

Thanks!  That worked.

Please mark the topic for Solved. It should be a good practice.

Share this post


Link to post
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