Jump to content

how to use the "or" operator


t0ddie
 Share

Recommended Posts

i dont know how to use the or operator. when i run this code, i get an error saying that if statements must have a then statement.

if $diecode <> 1000 Or

0100 Or

1010 Or

0110 Or

1110 Or

0111 Then

$diecode = "error"

EndIf

please, tell me whats wrong here lol. thanks.

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

Look at this example :

If "blubba" = "blabby" or "blubb" = "blubb" Then
MsgBox(64,"","Hi Blubba/Blubb !")
Else
MsgBox(64,"","Damn..where is Blubba and Blubb ?")
EndIf

Good luck !

(Edit : me....types....slow....morning...zzz)

Edited by Helge
Link to comment
Share on other sites

$diecode <> 1000 Or 0100

...

please, tell me whats wrong here lol. thanks.

<{POST_SNAPBACK}>

If I got the AutoIt syntax right, the clear text equivalent of this is:

"If it is true that $diecode is not equal to 1000 or if 0100 is true, then this expression is true, otherwise it is false."

Since 0100 means true (all non-zero numbers mean true), this expression is always true.

OTOH, if I read your mind correctly, you actually wanted to say:

"If it is true that $diecode is neither equal to 1000 nor equal to 0100, then this expression is true, otherwise it is false."

That is:

$diecode <> 1000 And $diecode <> 0100
much like Helge's example. BTW never mind the strange strings in Helge's example. In Norway they talk (and perhaps even think) like that.

You can try using parentheses to make expressions with And and/or Or easier to understand.

($diecode <> 1000) Or (0100)
($diecode <> 1000) And ($diecode <> 0100)

Edit: corrected Or/And mistakes :idiot: , thanxalot to philip123adams

Edited by Henrik

Ignorance is strength.

Link to comment
Share on other sites

I think you have two issues. One is, I think, you want to use "And" instead of "Or" in this case. The second is if you want to span multiple lines end each line, that is spanning, with an underscore character. The lack of underscores is what produced the error statement.

$Diecode = "abc"

if $diecode <> 1000 And _

$diecode <> 0100 And _

$diecode <> 1010 And _

$diecode <> 0110 And _

$diecode <> 1110 And _

$diecode <> 0111 Then

$diecode = "error"

EndIf

msgbox(4096, "answer", $Diecode)

Phillip

Link to comment
Share on other sites

ok, when i add this...

$Diecode = "abc"

if $diecode <> 1000 And _

$diecode <> 0100 And _

$diecode <> 1010 And _

$diecode <> 0110 And _

$diecode <> 1110 And _

$diecode <> 0111 Then

$diecode = "error"

EndIf

i get an error at line 85, and it never did that before.

this is line 85.

$diecode1 & $diecode2 & $diecode3 & $diecode4 = $diecode

and the error i get is

Error: Expected a "=" operator in assignment statement.

whats wrong here?

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to comment
Share on other sites

ok, when i add this...

$Diecode = "abc"

if $diecode <> 1000 And _

$diecode <> 0100 And _

$diecode <> 1010 And _

$diecode <> 0110 And _

$diecode <> 1110 And _

$diecode <> 0111 Then

$diecode = "error"

EndIf

i get an error at line 85, and it never did that before.

this is line 85.

$diecode1 & $diecode2 & $diecode3 & $diecode4 = $diecode

and the error i get is

Error: Expected a "=" operator in assignment statement.

whats wrong here?

<{POST_SNAPBACK}>

The statement is structured backward. It should be:

$diecode = $diecode1 & $diecode2 & $diecode3 & $diecode4

Phillip

Link to comment
Share on other sites

If Not StringInString("1000,0100,1010,0110,1110,0111" , $diecode) Then
  $diecode = "error"
EndIf

<{POST_SNAPBACK}>

excellent work.

i learn alot from this forum. thanks

EDIT: StringInStr :idiot:

Edited by t0ddie

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

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