if-statement

Ant (1.6.5) - How to set two properties in one <condition> or <if>

I am trying to assign two different strings to two different variables dependent on two booleans in Ant. Pseudocode (ish): if(condition) if(property1 == null) property2 = string1; property3 = string2; else property2 = string2; property3 = string1; What I've tried is; <if> <and> <not><isset propert...

alternative to if statement in java

I am curious to see any alternative(s) to the regular if statements such as if(x) do a; if(y) do b; if(z) do c; so as you see all if statements are seperate and no else condition. Please notice that X Y Z are totally seperate conditions so switch wouldn't fit. ...

INSERT IF NOT EXISTS type function for me to use without turning the column into primary key?

This script I'm working on is taking data from the web using python's urllib2 module and then putting it in a table. This data is basically just going to be in a table with one column and one row. How do I have it so that when I run the script it just updates the record? I don't want to make it a primary key because I'm probably going...

More than one value in Smarty {if}

Hy i have this code. {if $isModerator && $order->kind==1} bla bla {/if} and $order->kind can be 1,2,3,4,6 so making 5 if is not the idea any idea? ...

Combining IF else with LEFT to hide columns

Hi Guys I'm trying to write some code to Hide columns if the first 3 characters of cells in a range equal the contents of another. I have the code for hiding columns if cells in a range are blank as this;- Private Sub Worksheet_Change(ByVal Target As Range) Dim r As Range, cell As Range On Error GoTo ErrHandler Set r = Me.Range("C8:R8...

Two If selection while a select query

Hello I have this query : SELECT o.id, o.id as oid, o.id as orderId, o.cid, o.date, o.state, o.price, o.currency, o.lastChange, o.url AS permalink, o.period, o.bloggerId, o.bloggerShare, o.offerValidity, o.rebate, o.cid, o.reason, o.bidReason, o.bidDate, o.bidPeriod, o.rate, o.lastChange2, o.permalinkDate, o...

Simple if statement in Java

How do i write an if statement in Java that displays Goodbye! if the variable word contains a letter d? Thanks to everyone. ...

How to tidy up too many if statements for readability

I have an example of some code that I see often in websites that I'd like to improve and would appreciate some help. Often I see 5-10 nested if-statements in a page_load method which aim to eliminate invalid user input, but this looks ugly and is hard to read and maintain. How would you recommend cleaning up the following code example? ...

MutableArray loaded with a .plist file Boolean Value. How do I test whether True or False??

I seem to have a problem understanding how to conditionally test a boolean value loaded from a .plist to a mutablearray. I simply dont understand what i am supposed to do and continue to receive an error: Passing argument 1 of 'numberWithBool:" makes integer from pointer without a cast. any help understanding this is appreciated! he...

Multiple Select Statements within IF

I could use some help to write a prog./sql construct for a report.. The Sql should first check for the prompt & then decide which "select" statements should run something like (pseudo-code) Select ACCT,LOC FROM ( IF :loc = 'MN' THEN Select acc as ACCT,location as LOC ELSE IF :loc = 'MA' THEN Select accid as ACCT,loc...

One Line 'If' or 'For'...

Every so often on here I see someone's code and what looks to be a 'one-liner', that being a one line statement that performs in the standard way a traditional 'if' statement or 'for' loop works. I've googled around and can't really find what kind of ones you can perform? Can anyone advise and preferably give some examples? For example...

"Number line" style of comparisons

I recently read in Code Complete that the recommended way of handling expressions that involve numbers is to order them like a number line. The book has 2 examples: if ( (MIN_ELEMENTS <= i) && (i <= MAX_ELEMENTS) ) if ( (i < MIN_ELEMENTS) || (MAX_ELEMENTS < i ) ) With the first example showing that i is between the min and max elem...

Javascript - if statement not working?

I'm trying to set a class to active depending on the url. I'm trying to use the code below, but in every case, it activates the active class for the second tab. var pathname = window.location.pathname; if(pathname = '/learn/subsection2') { $("ul.tabs li:eq(1)").addClass("active").show(); //Activate second tab ...

C++ String manipulation - if stament

I have the following code that works correctly. However after I add an else statement anything always evaluates to else wgetstr(inputWin, ch); //get line and store in ch variable str = ch; //make input from char* to string if(str=="m" || str=="M"){ showFeedback("Data Memory Updated"); } if(str=="p" || ...

Troubles formatting if statements in SQL

I've created the following sql statement, every thing in $() is a variable (comes from the module we're using on our site so $(varname) is the right format in this case, not @varname. It keeps telling me there's an error near THEN... how am I supposed to format this properly? IF ($(Shiptobilling) = 'yes') THEN BEGIN CardOrd...

PHP if or statement not working

We are trying to use the below piece of code if (($_GET['1'] != "1") || ($_GET['1'] != "2")) { When we try this no matter what value the variable has it will evaluate as true even when data is entered that is false. When we use if (($_GET['1'] == "1") || ($_GET['1'] == "2")) { and put in data that will make it return false it work...

&& (AND) and || (OR) in Java IF statements

My question might be very basic but still I think it worths to ask. I have the following code: if(!partialHits.get(req_nr).containsKey(z) || partialHits.get(req_nr).get(z) < tmpmap.get(z)){ partialHits.get(z).put(z, tmpmap.get(z)); } where partialHits is a HashMap. What will happen if the first statement is true? Will Java s...

Is it bad practice to change state inside of an if statement?

I wrote some code that looks similar to the following: String SKIP_FIRST = "foo"; String SKIP_SECOND = "foo/bar"; int skipFooBarIndex(String[] list){ int index; if (list.length >= (index = 1) && list[0].equals(SKIP_FIRST) || list.length >= (index = 2) && (list[0] + "/" + list[1]).equals(SKIP_SECOND)){ r...

Detect months with 31 days

Is there an analogous form of the following code: if(month == 4,6,9,11) { do something; } Or must it be: if(month == 4 || month == 6 etc...) { do something; } I am trying to write an if statement that checks if this month has more than 31 days. EDIT I guess the real problem is I undersand some of what I am taught but every ti...

<c:if> tag for JSF page

Used to develop Portlets and JPS's, so have a dilemma. task: display <h:dataTable> only when list isn't empty Is it possible to provide <c:if> tag for JSF page? ...