Jump to content
Sign in to follow this  
jackraymund

problem with "if"

Recommended Posts

jackraymund

if "c937ce9cfc504995e08c10dfad9e76e6" <> 0 then msgbox(0,"","")

but that works

if not "c937ce9cfc504995e08c10dfad9e76e6" = 0 then msgbox(0,"","")

its the same, but why first didnt work, and second work?...

Edited by jackraymund

thanks you BrewManNH

Share this post


Link to post
Share on other sites
czardas
You should get a message with both because you use the boolean NOT operator on the second example. Both expressions evaluate to True. In fact both expressions say the same thing. Edited by czardas
  • Like 1

Share this post


Link to post
Share on other sites
jackraymund

but i getting message only with second, first didnt work... try it

if "c937ce9cfc504995e08c10dfad9e76e6" <> 0 then consolewrite("1" & @CRLF)

if not "c937ce9cfc504995e08c10dfad9e76e6" = 0 then consolewrite("2" & @CRLF)

@edit

if not "c937ce9cfc504995e08c10dfad9e76e6" <> 0 then consolewrite("3" & @CRLF)

that return false too...

42e0ae3b87a2fcb097215f5a03565e69

d5a681de57f3a7318789a2eebc1a5157

faba1a16c0b656ba961cb7724c114353

1e2653ff6dedb66dee5035744bcffaa8

c937ce9cfc504995e08c10dfad9e76e6

c1e8dee81f5a221bd4628229d6d64160

bbb5310e3a4f7648d1a35ffe4af4eef0

dbeedb7e655e96ce496af4496d0b2a34

global $works[8] = ["42e0ae3b87a2fcb097215f5a03565e69","d5a681de57f3a7318789a2eebc1a5157","faba1a16c0b656ba961cb7724c114353","1e2653ff6dedb66dee5035744bcffaa8","c937ce9cfc504995e08c10dfad9e76e6","c1e8dee81f5a221bd4628229d6d64160","bbb5310e3a4f7648d1a35ffe4af4eef0","dbeedb7e655e96ce496af4496d0b2a34"]
for $i = 0 to UBound($works) - 1
if $works[$i] <> 0 then consolewrite($works[$i] & @CRLF)
Next

only 2 strings works, why?

Edited by jackraymund

thanks you BrewManNH

Share this post


Link to post
Share on other sites
AZJIO

jackraymund,

read the help file section operators.

strings are converted to numbers using "Number"

The "Not" operator has a higher precedence than "="

Edited by AZJIO
  • Like 1

Share this post


Link to post
Share on other sites
jackraymund

ok, i solve the problem 0 is a int, not string, its realy crazy lol

global $works[8] = ["42e0ae3b87a2fcb097215f5a03565e69","d5a681de57f3a7318789a2eebc1a5157","faba1a16c0b656ba961cb7724c114353","1e2653ff6dedb66dee5035744bcffaa8","c937ce9cfc504995e08c10dfad9e76e6","c1e8dee81f5a221bd4628229d6d64160","bbb5310e3a4f7648d1a35ffe4af4eef0","dbeedb7e655e96ce496af4496d0b2a34"]
for $i = 0 to UBound($works) - 1
if String($works[$i]) <> string(0) then consolewrite($works[$i] & @CRLF)
Next
Edited by jackraymund

thanks you BrewManNH

Share this post


Link to post
Share on other sites
AZJIO

Global $works[8] = [ _
"42e0ae3b87a2fcb097215f5a03565e69", _
"d5a681de57f3a7318789a2eebc1a5157", _
"faba1a16c0b656ba961cb7724c114353", _
"1e2653ff6dedb66dee5035744bcffaa8", _
"c937ce9cfc504995e08c10dfad9e76e6", _
"c1e8dee81f5a221bd4628229d6d64160", _
"bbb5310e3a4f7648d1a35ffe4af4eef0", _
"dbeedb7e655e96ce496af4496d0b2a34"]
For $i = 0 To UBound($works) - 1
    If $works[$i] <> '0' Then ConsoleWrite($works[$i] & @CRLF)
    If Not ($works[$i] == 0) Then ConsoleWrite($works[$i] & @CRLF)
Next

  • Like 1

Share this post


Link to post
Share on other sites
czardas

Okay I made a mistake. I get what's going on now. Compare the following:

if not "c937ce9cfc504995e08c10dfad9e76e6" = 0 then msgbox(0,"","Without parenthesis")

if not ("c937ce9cfc504995e08c10dfad9e76e6" = 0) then msgbox(0,"","With parenthesis")
Edited by czardas
  • Like 1

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
Sign in to follow this  

×