if-statement

does the condition after && always get evaluated

I have this if statement that tests for the 2 conditions below. The second one is a function `goodToGo() so I want to call it unless the first condition is already true $value = 2239; if ($value < 2000 && goodToGo($value)){ //do stuff } function goodToGo($value){ $ret = //some processing of the value return $ret; } My ques...

Delphi Performance: Case Versus If

I guess there might be some overlapping with previous SO questions, but I could not find a Delphi-specific question on this topic. Suppose that you want to check if an unsigned 32-bit integer variable "MyAction" is equal to any of the constants ACTION1, ACTION2, ..., ACTIONn, where n is - say 1000. I guess that, besides being more elega...

If statement structure in PHP

I keep getting an error with the following bit of code. It is probably some small thing but I don't see what is wrong. while($row = mysql_fetch_array($result)) { $varp = $row['ustk_retail']; if ($varp<80000) { $o1 = 1; } if (($varp=>80000) 100000)) { $o2 = "1"; } if (($varp=>100000) 120000)) { $o3 = "1"; } if (($varp=>...

check if(country == @"(null)" doesn't work

hi all, I got the problem that the if-statement doesn't work. After the first code line the variable contains the value "(null)", because the user who picked the contact from his iphone address book doesn't set the country key for this contact, so far so good. but if I check the variable, it won't be true, but the value is certainly "(...

jquery binding verification

Is there a way in jQuery to know if an element already has an event bound to the click or doubleclick? ...

Union and If Exists - not working together - Please help

I need to get dummy values if they do no rows returned from table. The If exists works by itself, but gives error with a Union. Can someone please guide me with a solution or a workaround? create table test1 (col1 varchar(10)) create table test2 (col1 varchar(10)) create table test3 (col1 varchar(10)) insert test1 values ('tes...

If statement not effective

void spriteput(int x,int y, int stype) { char sprite1[5]="OOOO"; char sprite2[5]="OOOO"; char sprite3[5]="OOOO"; char sprite4[5]="OOOO"; if (stype == 1) { char sprite1[5] = " OO "; char sprite2[5] = "OOOO"; char sprite3[5] = "OOOO"; char sprite4[5] = " OO "; mvprintw(2,y,"%s...

java equivalent of Delphi NOT

In Delphi I can do the following with a boolean variable: If NOT bValue then begin //do some stuff end; Does the equivalent in Java use the !? If !(bValue) { //do some stuff } ...

How does switch compile and how optimized and fast is it?

As I found out that I can use only numerical values in C++'s switch statements, I thought that there then must be some deeper difference between it and a bunch of if-else's. Therefore I asked myself: (How) does switch differ from if-elseif-elseif in terms of runtime speed, compile time optimization and general compilation? I'm mainly ...

Is there a more elegant solution than an if-statement with no else clause?

In the following code, if Control (the element that trigers Toggle's first OL) is not Visible it should be set Visible and all other Controls (Controls[i]) so be Hidden. .js function Toggle(Control){ var Controls=document.getElementsByTagName("ol",document.getElementById("Quote_App")); var Control=Control.getElementsByTagName("...

SQL - Conditionally evaluate WHERE clauses

I need to get a WHERE clause to only evaluate certain statements. something like: WHERE field_a = field_b AND (CASE WHEN <PARAM>type</PARAM> = 5 THEN {field_c = 1 OR field_c = 2} WHEN <PARAM>type</PARAM> = 6 THEN {field_c = 3 OR field_c = 4} ELSE field_c = <PARAM>type</PARAM> so that when the Param type = 5...

Try Catch - Finally in If statement, how to go on after ?

how can I do that ? void x() {.... if (...) {try {} catch (ComException com) { throw com} finally // in any case, executed fine! {...instructions.......} } ... instructions...// not executed in case of exception because the finall...

how to echo data that we read with file_get_contents

i want to check remote url's page contents. IF remote site's page content contains string http://yahoo.com set $qqq = YH if not contains $qqq = NOYH. i am not talking about "url of that page" im talking about page content of url $url = "'".$get['url']."'"; $needle = "http://yahoo.com/"; $contents = file_get_contents($url); if(stripos($c...

T_BOOLEAN_AND error?

whats wrong with this? anybody help me please.. if(stripos($nerde, $hf) !== false) && (stripos($nerde, $rs) !== false){ @mysql_query("update table set dltur = '3' where id = '".$ppl[id]."'"); } else { //dont do anything } i get T_BOOLEAN_AND error. ...

Easy way to check if item is in list?

Hey guys, I'm writing a search algorithm in C++, and one of the things I need to do is have a few if statements that check cells above, below, left of, and right of. Each time a cell is found to be open and added to the stack, I want it added to a list of cells already checked. I want to be able to say in the if statement if(thisCell ...

What's the difference between those PHP if expressions!?

Hello, What's the difference between those PHP if expressions!? if ($var !== false) { // Do something! } if (false !== $var) { // Do something! } Some frameworks like Zend Framework uses the latest form while the traditional is the first. Thanks in advance ...

matching an element's class to another element's ID, or *part* of another element's ID

hello again Such a simple concept but I'm struggling to express it ... apologies in advance for my verbosity. I have a container div with a class, e.g., ; I want to use that class to do two things: add a class (e.g., 'active') to the nav element whose ID matches the class of div#container (e.g., #nav-primary li# apples) add the same...

how to include multiple if statement conditions in jQuery

I have an if statement that needs to look like this: UPDATE $("input#textbox").keypress(function(e){ key==e.which; if($("input#textbox").length <=7 && (key===13 || $("div#search-button").click())){ /////SOME FUNCTION//// }; }); I'm trying to execute the "SOME FUNCTION" area only if the input length is <=7 and eith...

how can I determine the path of a site using php/smarty?

Ok, say I have a page with the url: URL.com/checkout/completed, how can I setup an if statemet to perform: <if "This page has url of checkout/completed"> No Content <else> Content </if> Is there a way? A simple way, my php/smarty-fu lacks.. A lot. EDIT: {if $smarty.server.REDIRECT_URL eq 'http://www.euroworker.no/checkout/comple...

Dynamics CRM 4.0 J Script - 'If' statement using statecode

Hi I am trying to create a simple alert as an onload event on the contact entity. However, I only want this to trigger if one of the conditions is that the contact is still active. I therefore put it the following: if (crmForm.all.statecode.DataValue == 0) { alert("'Whatever alert I want") ; } However, when I load the contact reco...