if-statement

confusing use of a comma in if statement

I have this piece of code in c++ ihi = y[0]>y[1] ? (inhi=1,0) : (inhi=0,1); But how would it look in C#? Many thanks, ...

Why would this line of code be executed if the IF condition is false? Doesn't make any sense.

Here's the code: <?php class Order extends Zend_Db_Table_Abstract { protected $_name = 'orders'; protected $_limit = 200; protected $_authorised = false; public function setLimit($limit) { $this->_limit = $limit; } public function setAuthorised($auth) { $this->_authorised = (bool) $auth; } public function insert(arr...

PHP: if !empty & empty

Hello. So i have this form.. With 2 fields. "Youtube" and "link" I want to do if you have filled in YouTube, it should do this: if(!empty($youtube)) { if ($pos === false) { echo "Du skal indtaste youtube et URL, som starter med 'http://www.youtube.com/watch?..&lt;br&gt;"; echo "<br> Har du ikke din video på YouTube, skal du ikke udf...

Javascript: Clear onSubmit, two fields

Hey, help would be very much appreciated. How do I make an ifstatement so both of these fields "szValue" and "szPara" clear onSubmit? Thanks! function submit() { if (document.getElementById('szValue').value === "Enter First Value") { document.getElementById('szValue').value = ""; } if (document.getElementB...

Confusing If Statement?

I always use If statement (In C#) as (1. Alternative); if (IsSuccessed == true) { // } I know that there is no need to write "== true" as (2. Alternative)); if (IsSuccessed) { // } But, I use it because it is more readable and cause no performance issue. Of course, this is my choice and I know many software developers prefer ...

how to access i statement in usercontrol...

How can I go about accessing the result of an if statement in a user control? UserControl code: public bool SendBack(bool huh) { if(huh) huh = true; else huh = false; return huh; } And in a separate project i am trying to access it like this: private void button1_Click(object sender, EventArgs e) { MyCont...

How can I simplfy this logic

I'm having trouble simplifying this conditional statements logic. Is there a more effervescent way of writing this? if(($x || $a) && ($x || $y)) { if($x){ return true; } } return false; ...

In C# is it possible to evaluate if a variable is different of null without using an operator ?

For instance is it possible to write this if (variable != null) without using the operator != or == ? ...

C: Convert A ? B : C into if (A) B else C

I was looking for a tool that can convert C code expressions for the form: a = (A) ? B : C; into the 'default' syntax with if/else statements: if (A) a = B else a = C Does someone know a tool that's capable to do such a transformation? I work with GCC 4.4.2 and create a preprocessed file with -E but do not want such structures...

PHP if statement - select two different get variables?

Below is my example script: <li><a <?php if ($_GET['page']=='photos' && $_GET['view']!=="projects"||!=="forsale") { echo ("href=\"#\" class=\"active\""); } else { echo ("href=\"/?page=photos\""); } ?>>Photos</a></li> <li><a <?php if ($_GET['view']=='projects') { echo ("href=\"#\" class=\"active\""); } else { echo ("href=\"/?page=photos...

Mixing regular expression and other conditional expression in a bash if statement

I can't get around this for quite sometime now. As I read along manuals and tutorials I'm getting more confused. I want an if statement with the following logic: if [ -n $drupal_version ] && [[ "$drupal_version" =~ DRUPAL-[6-9]-[1-9][1-9] ]]; then but I can't get it to work properly. When the script is evaluated using the "bash -x .....

Why do I need the isset() function in php?

I am trying to understand the difference between this: if (isset($_POST['Submit'])) { //do something } and if ($_POST['Submit']) { //do something } It seems to me that if the $_POST['Submit'] variable is true, then it is set. Why would I need the isset() function in this case? ...

Nested IF statements in Excel [Over the 7 allowed limit]

hey guys, i am trying to create a spreadsheet which automagically gives a grade to a student based on their marks they got. I've apparently hit excels nested IF statement limit which is 7. here's my if statement: =IF(O5>0.895,"A+",IF(O5>0.845,"A",IF(O5>0.795,"A-",IF(O5>0.745,"B+",IF(O5>0.695,"B",IF(O5>0.645,"B-",IF(O5>0.595,"C+",IF(O5...

How to use "if clause" in xhtml?

Hi , i am a newbie C# Programmer. I have a problem in xhtml. I want to check that if browser is IE6 or not. For example if ie6 then div id="div1" style="display:block;" else div id="div1" style="display:none;"> How can i control my browser and use if clause in xhtml? ...

PHP IF statement not taking variable into account!

I have a tabled view in a while loop, where a user can view information on books. For example, book ISBN, book name, read status... Basically, when the user sets their 'readstatus' to 'complete' I want that specific table row to become grey! The logic is very straight forward, however I can't get my IF statement to recognise this: if ...

Compare a specific array element to a char with "if" in C?

Rather Trivial Question. So I tried to do this: if(array[0]=="some_string") but obviously it doesn't work... What do I have to do? ...

Simple if statement for checking whether a co-ordinate is inside a square?

I have an UIImageView and taking the raw touch input. I need to check if a touch is within a certain set of squares. At the moment... I have this if statement.... if(46 < touchedAt.x && touchedAt.x < 124 && 18 < touchedAt.y && touchedAt.y < 75) but I have tried to simplify it to this one... if(46 < touchedAt.x < 124 && 18 < touchedA...

So, I guess I can't use "&&" in the Python if conditional. What should I use in this case? Any help?

Here's my code: # F. front_back # Consider dividing a string into two halves. # If the length is even, the front and back halves are the same length. # If the length is odd, we'll say that the extra char goes in the front half. # e.g. 'abcde', the front half is 'abc', the back half 'de'. # Given 2 strings, a and b, return a string of th...

Why is PHP not allowing comparison?

I'm using PHP to read if an entry in my table on the database is set to "yes" or "no" and auto check the radio button that corresponds: <?php include 'file.php'; $query = "SELECT * FROM TABLE"; $runquery = odbc_exec($connect,$query); $status= odbc_result($runquery,"status"); odbc_close($file); ?> <form> <div class="formContainer"> ...

Bash: Continue script if only one instance is running.

Hello, now this is embarrassing. I'm writing quick script and I can't figure out why this statement don't work. if [ $(pidof -x test.sh | wc -w) -eq 1 ]; then echo Passed; fi I also tried using back-ticks instead of $() but it still wouldn't work. Can you see what is wrong with it? pidof -x test.sh | wc -w returns 1 if I run it insi...