gdgrana: (argh)
[personal profile] gdgrana
I feel REALLY stupid for asking this, as I'm sure the answer is right in front of me, but for the life of me I can't figure this out.

How do I properly code up nested arguments for an "if" statement?

Example: two variables "varA" and "varB" have been assigned their values. I want to check what those values are before acting on the rest of the script: specifically, "varA" should be some value "foo" AND "varB" should be neither "bar" or "baz".

Here's how I thought it should go:

if (varA == "foo") && ( (varB != "bar") || (varB != "baz") )
{
do something;
}

When I do this, though, it seems to ignore the "varB" stuff and only acts on all instances where "varA" is "foo". The problem must be in how I nest the "varB" conditions, since if I remove one of them and fix the parenthesis accordingly, it works for that value of "varB". I have no idea how to make it work for my needs, however.

Thanks for y'alls input.


EDIT: Figured it out. Boolean fail on my end >|
From:
Anonymous( )Anonymous This account has disabled anonymous posting.
OpenID( )OpenID You can comment on this post while signed in with an account from many other sites, once you have confirmed your email address. Sign in using OpenID.
User
Account name:
Password:
If you don't have an account you can create one now.
Subject:
HTML doesn't work in the subject.

Message:

 
Notice: This account is set to log the IP addresses of everyone who comments.
Links will be displayed as unclickable URLs to help prevent spam.

August 2010

S M T W T F S
1234567
891011121314
15161718192021
22232425262728
29 3031    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 26th, 2017 06:46 pm
Powered by Dreamwidth Studios