if-statement

Full if/else statement vs. Conditional Operator

Possible Duplicates: Benefits of using the conditional ?: (ternary) operator Is the conditional operator slow? Hi all, I've got a pretty simple question regarding the different if/else statements. Apart from writing less code, are there any other benefits for using the conditional operator as opposed to the full if/else st...

Python newbie: "if X == Y and Z" syntax

Does this if key == "name" and item: mean this? if key == "name" and if key == "item": If so, I'm totally confused about example 5.14 in Dive Into Python. How can key be equal to both "name" and item? On the other hand, does "and item" simply ask whether or not item exists as a variable? Thanks. ...

In Java, is this considered an example of a "nested IF statement"?

Here we have a long-standing assumption that needs to be cleared up in my head. Is the following an example of nesting 'if' statements: if (...) ...; else if (...) ...; I was under the impression that nesting required an 'if' inside another 'if', like so: if (...) if (...) ...; or at least a clear separation of scope when...

Help with if statement

I'm trying this part of my script and it work perfectly if win32gui.GetCursorInfo()[1] == 65567: but when I'm trying to add this win32gui.GetCursorInfo()[2] == categoriesScreenPos[1]: it stop working... why? The categoriesScreenPos[1] is the same value (17,242) of the position of the cursor, but the if doesn't work... Full if: i...

if statement doesn't work in Jquery Ajax call?

I used if statements before in a the success function of an ajax call but for the life of me I can't get this to work. I can alert all VARS and they show the data, but the condition statement will not work. What am I doing wrong? I just can't get it. jQuery.ajax({ type: "POST", url: "/ajax/uiProcessPhoto...

Looking for help to improve basic Java code. Too many if's!

Hey guys, I know this is a rather trivial question, but what is the best way handle this situation? I have several cases and I am just using simple if, if elses. I remember using a look up table at one point and I drew one out on paper, but I am not sure how to implement it in Java. Any tips would be appreciated, even if the answer is th...

ExpressionEngine 1.6.9: display DIV at particular pages generated by same template

Hi friends, I'm a EE newbie. I have a template for subpage. all subpages use same subpage template. But for some sub pages I need to put an extra div (kinda info box), how can I put a condition? do I have to create a separate template only for a small div difference? urls are consistent, so if i can make a url check and display div fo...

Javascript if statement refuse to load correctly from exterior script IE6 IE5.5

I see a very funny behaviour in my page when it comes to IE6 and IE5.5. I have a script (supersleight if you know about it) that puts PNG's back in business when dealing with IE6 and IE5.5. During execution of this, I want to change the background into using the Explorer alpha filter (if Javascript is turned on, use filter, otherwise sti...

What does an if look like in IL?

What does an if statement look like when it's compiled into IL? It's a very simple construct in C#. Can sombody give me a more abstract definition of what it really is? ...

How to avoid multiple nested IFs

I am currently trying to restructure my program to be more OO and to better implement known patterns etc. I have quite many nested IF-statements and want to get rid of them. How can I go about this? My first approach was to get it done with exceptions, so e.g. public static Boolean MyMethod(String param) { if (param == null) throw n...

Help with a php if statement...

Hello there! can somebody help me with this if statement? My form appears every-time I load the page but it disappears after I submit the form! Maybe it's the "endif" syntax that confuses me but I can't get this done properly... here is the code: <?php if ($this->input->post('submit') && $this->input->post('categories')): foreach($tag...

How to add a class with if statement in conditional statement with jquery?

I am having a problem with IE7 in a certain page where URL has katoder, http://www.mywebsite.com/Kalde_katoder.asp I want to add a class ie7 to id system. I tried this but it does not work. Could anyone point me to the right direction? Thanks in advance. <!--[if IE 7]> <script type="text/javascript"> $(document).ready(function() ...

find out the parent of a link and pre-pend it with somethin

I'm trying do something like this if ($(this).parent() == $('div.propdata')){ $(this).prepend('<a class="booknow2 sidelink" href="../../availability/default.aspx"><span>Book now &raquo;</span></a>'); } By the way $(this) is evenprop Can't seem to get it to work This is my code <div class="propdata" id="FARM"><div class="evenprop...

Batch command for if filename contains "X"?

I'm trying to run a batch file through a folder and delete files if their name contains a certain string. I'm not sure how to check the filename against the string though. ...

What is wrong with this if-elsif-else block in my Perl script?

I'm trying to write a condition for a nested if statement, but haven't found a good example of using or in if statements. The following elsif condition fails and allows the code nested beneath it to fire if $status == 6: if ($dt1 > $dt2 ) {do one thing} elsif(($status != 3) || ($status != 6)) { do something else} else {do something com...

how do I create an indented block in Python?

for example, how to I enter this in Python so that it is indented correctly? if 1 + 2 == 2: print "true" print "this is my second line of the block" print "this is the third line of the block" ...

Why won't this work as an IIF function, but will as an IF Statement?

The following works: If 1=1 rdoYes.checked = True Else rdoNo.checked = True End If However, the following doesn't work: IIF(1=1, rdoYes.checked = True, rdoNo.checked = True) Why is this? Thanks! ...

How to write a true if()

I always write if statements like this: if (...) { /* do something */ } When I create topics on stackoverflow, sometimes people change this code to: if (...) { /* do something */ } So the first { goes to a new line. Does it make sense, what's the true way? ...

MySql: What is the structure for "IF" formula? Please give example.

I try to use formula "IF" in view but dont know what the structure. Basically I try to divide two group of number. 0,1,2,3,4 after "IF" = 0 and 5,6,7,8,9 after "IF" = 1. Here is an example of my database: Row 1 / Column A = 8 column B = 1 column C = 2 Column D = 5 Column E = 7 Column F = 9 ...

Forms PHP IF Statement

Hi, I have a HTML form, which includes radio buttons that the user can select if he wants to sign up for multiple years in order to get a discount. At the moment, i have a PHP if statement that basically says IF the user selects yes for the discount, calculate the price, display details in a table, perform SHA1HASH conversion, and the...