conditional

C# conditional AND (&&) OR (||) precedence

We get into unnecessary coding arguments at my work all-the-time. Today I asked if conditional AND (&&) or OR (||) had higher precedence. One of my coworkers insisted that they had the same precedence, I had doubts, so I looked it up. According to MSDN AND (&&) has higher precedence than OR (||). But, can you prove it to a skeptical co...

Writing conditional rule using jQuery validation

Hi I have a simple modal popup which has 3 name fields and 3 e mail fields adjacent to each other. I am new to jQuery so can any one please help me how to write a logic for the following case? The first name field and Email field are mandatory so I kept the class as required fields but the other two name and e-mail fields are optional b...

XAML Conditional Compilation

Is there an easy way to use the same conditional compilation symbol that I'm using for my c# code, in my xaml files? ...

refactoring multiple if-else conditionals in a method

I am in the process of refactoring my existing code. It actually works fine, but it is a bit cluttered with multiple if-else conditionals checking the value of one variable and change the value of a second variable to an updated value taken from a fixed enumeration structure. else if (var1 == 'valueX') { if (var2 == MyEnum.A) var2 = ...

referencing each case of a switch from a conditional inside a different method in java

Hello, I am implementing some methods which use switch statements to distinguish between different cases: private void doThis(){ switch(command){ case on: {status = doCalculationsA; break;} case off: {status = doCalculationsB; break;} case idle: {status = doCalculationsC; break;} case stdby:{status = doCalculationsD;...

conditional foreach loop c#

How can i do this? (c#) Basically, i want to be able to sort of, comment out a bracket. but not really. I guess I want to close brackets out of order. That's probably not possible. I can obviously implement this in full separate if clauses, but this would considerably lighten my code. P.S.: I am trying to place the "//do something" code...

Which SQL do you write?

When joining two tables, what are the difference between the two blocks below and which is the better approach? Pattern A: SELECT ... FROM A INNER JOIN B ON A.PK = B.FK WHERE 1=1 AND A.Name = "Foo" AND B.Title = "Bar" Pattern B: SELECT ... FROM A INNER JOIN B ON A.PK = B.FK AND B.Title = "...

conditional join in mysql

Hi, I have a table id1, id2, type. type is an enumerated value containing a name of another table. I'd like to preform a join with the name of the table of type. For example: switch($type) case 'table1': join table1; break; case 'table2': join table2; break; How can I achieve this? ...

Which conditional statement is faster in SQL?

SELECT a, b FROM products WHERE (a = 1 OR b = 2) or... SELECT a, b FROM products WHERE NOT (a != 1 AND b != 2) Both statements should achieve the same results. However, the second one avoids the infamously slow "OR" operand in SQL. Does that make the 2nd statement faster? ...

PHP Conditional Logic

In PHP, is the following logic allowed If (x && y) //Do A Elseif (x) // Do B Elseif (y) // Do C Else // Do D Basically, are you allowed to use more than one elseif? ...

Conditional Count on a field

Hello, If I had a table like this: jobId, jobName, Priority Whereby Priority can be an integer between 1 to 5. Since I would need this query for generating a chart on report, I would need to display the jobid, jobname and 5 fields called Priority1, Priority2, Priority3, Priority4. Priority5. Priority1 should count the amount of r...

Centering Text in IE 7 / Conditional CSS

i'm really banging my head on this one. The site looks great in everything but IE7 and I've tried everything I know to make it center. http://talentforceinc.com/Employer%5FHome.html I've got conditional CSS for IE declared, and have added inline text-align:center tags, but for an unknown reason the text in the multi-colored bar on the...

Excel - bottom border if text is present?

Hi, I'm creating an invoice at the moment, and there's going to be varying amounts of text on each invoice. Ideally I'd like to be able to enter content, and as soon as I do that, it'll create a border along the bottom of that row, from A to K if that makes sense. Is this possible? Cheers :) ...

How to return TRUE|FALSE from class in PHP

Hey there! I was wondering why my php program is not returning the correct TRUE FALSE value when the class is included elsewhere it goes something like this source: signup.php class signup { function buildProfile() { if($logic){ $this->success = TRUE; }else{ $this->success = FALSE; ...

TFSBuild:How to trigger a build only when a particular file is checked in?

We have a particular file, say X.zip that is only modified by 1 or 2 people. Hence we don't want the build to trigger on every check-in, as the other files are mostly untouched. I need to check for a condition prior to building, whether the checked-in item is "X.zip" or not.. if yes, then trigger a build, else don't. We use only CI bui...

How do I build XQuerys to include/exclude rows based on the presence of certain tags and attributes?

I have an auditing/logging system that uses raw XML to represent actions taken out by an application. I'd like to improve on this system greatly by using an XML column in a table in the application's SQL Server database. Each row in the table would contain one log entry and each entry should contain one or more tags that are used to de...

simplifying data structures and condition statements in python code

I was wondering if there are any ways to simplify the following piece of Code. As you can see, there are numerous dicts being used as well as condition statements to weed out bad input data. Note that the trip rate values are not all inputed yet, the dicts are just copied and pasted for now EDIT In any of the rates, (x,y):z . x and y a...

Mathematically Find Max Value without Conditional Comparison

----------Updated ------------ codymanix and moonshadow have been a big help thus far. I was able to solve my problem using the equations and instead of using right shift I divided by 29. Because with 32bits signed 2^31 = overflows to 29. Which works! Prototype in PHP $r = $x - (($x - $y) & (($x - $y) / (29))); Actual code for LEADS...

trouble making polymorphism defeat those switch/case statements

Continuing on previous questions (here, and here), I implemented a basic command pattern, created my command classes and coded to an interface, so when any command is used, to call the execute() method. However, I am still finding myself unable to shake those case statements: I am reading each character from a master/decision String, w...

How can I add an additional condition to this query (using CASE) ?

Here's my query so far: SELECT posts.title , SUM(CASE comments.status WHEN 'approved' THEN 1 END) AS commentsCount FROM posts INNER JOIN comments ON comments.postID = posts.id WHERE posts.status = ? GROUP BY posts.title ORDER BY commentsCount DESC ...