Jump to content
Sign in to follow this  
michaelslamet

IF question

Recommended Posts

michaelslamet

This look so noob and seems so inefficent:

If $avar = "" OR $another_var = "" OR $c1 = "" OR $d_var = "" OR $e_var = "" OR $another_var_again = "" OR $another_var_again2 = "" then
   ....
EndIf

 

Is there another way to write that If with many OR like above?

Share this post


Link to post
Share on other sites
jaberwacky

Here's how I would do it, one way among many really.

Not really inefficient I think.

 

If Not $avar              OR _
   Not $another_var       OR _
   Not $c1                OR _
   Not $d_var             OR _
   Not $e_var             OR _
   Not $another_var_again OR _
   Not $another_var_again2 then
   ....
EndIf

lookit how pritty

Edited by jaberwocky6669

Share this post


Link to post
Share on other sites
MHz

$avar = 'a'
$another_var = 'b'
$c1 = 'c'
$d_var = 'd'
$e_var = 'e'
$another_var_again = 'f'
$another_var_again2 = ''
Switch ''
    Case $avar, $another_var, $c1, $d_var, $e_var, $another_var_again, $another_var_again2
        MsgBox(0, '', 'It is an empty string, zero, false or anything else that is nothing')
EndSwitch

If you want to check for an empty string then you may need to use == in the 1st post

Share this post


Link to post
Share on other sites
michaelslamet

Aha, what is different between "=" and "==" ? Because I never use "==" before.

I'm open this thread because I remember I see it somewhere that (guiness??) write something like:

OR ($avar, $another_var, $cl, $d_var, $e_var, $another_var_again, $another_var_again2)

but I'm not remember about it and what is for

Share this post


Link to post
Share on other sites
MHz

Look at the help file AutoIt -> Language Reference -> Operaters

unofficially:

= will check the value. i.e. is it something, is it nothing, is it a numerical comparison etc.

== will check whether this string equals that string with case sensing. Like a contents check rather then a value check. If you check for "" then it will be true only if it is "".

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  

×