IF && THEN Controversy

Doesn’t this:

if (company == ‘’ || company == null)

mean the same as this:

if (company == ‘’ && company == null)

and when is it better to call a field on a tab panel by relation:

if (gconst01_to_address.address_num == 1 && gconst01_to_address.street != “” && gconst01_to_address.street != null)

or by hitting the element in this manner:

if (forms.tab_address_main.address_num == 1 || forms.tab_address_main.street != “” || forms.tab_address_main.street != null)

and why would both these scenarios above ignore my wishes and completely overwrite pre-existing text in the field?

Example:

if (gconst01_to_address.address_num == 1 && gconst01_to_address.street != “” && gconst01_to_address.street != null)
{
gconst01_to_address.street = ‘9999 Melrose Avenue’
}

Thanks!

|| is an OR operator
&& is an AND operator

So:

if (company == ‘’ || company == null)

is not equal to

if (company == ‘’ && company == null)

BTW: you can check for

company == ‘’ && company == null

easier by using

!company

Paul

PS: for the record: == is the equal operator, != is the not equal operator

Thanks Paul!

Good to know those shortcuts!

Althought, of course, it’s not doing it now, would there be any reason why the last example in my original post would clobber text that is already there?