condition

Why Switch/Case and not If/Else If?

This question in mainly pointed at C/C++, but I guess other languages are relevant as well. I can't understand why is switch/case still being used instead of if/else if. It seems to me much like using goto's, and results in the same sort of messy code, while the same results could be acheived with if/else if's in a much more organized m...

Is there a problem with this usage of boost condition code?

Will this code ever wait on the mutex inside the producer's void push(data)? If so how do I get around that? boost::mutex access; boost::condition cond; // consumer data read() { boost::mutex::scoped_lock lock(access); // this blocks until the data is ready cond.wait(lock); // queue is ready return data_from_queue(); } //...

Does CouchDB support multiple range queries?

How are multiple range queries implemented in CouchDB? For a single range condition, startkey and endkey combination works fine, but the same thing is not working with a multiple range condition. My View function is like this: "function(doc){ if ((doc['couchrest-type'] == 'Item') && doc['loan_name']&& doc['loan_period']&& ...

Javascript and DOM event interaction and possible race conditions

Scenario: Preloading images Perform an ajax query Show loading screen Retrieve results from ajax query Insert images into the dom Wait for images to finish loading Hide loading screen I was thinking of doing the following: function ajaxCallback(results) { /* snip insert into dom code */ $(".waitForLoad").each(function() { ...

Difference between Condition in Where and Condition in Join

Hi All Can anyone please explain to me why the following two queries yield different results? SELECT o.* FROM Customer c LEFT JOIN [Order] o ON o.CustomerID = c.CustomerID AND o.OrderType = 'Cash' WHERE c.Country = 'USA' SELECT o.* FROM Customer c LEFT JOIN [Order] o ON o.CustomerID = c.CustomerID WHERE ...

css style if else condition

I would like to use conditions in my css. The idea is, I have a variable that I replace when the site is run and generate the right stylesheet. I want that according to this variable the stylesheet changes! It looks like: [if {var} eq 2 ] background-position : 150px 8px; [else] background-position : 4px 8px; ...

Force GAC installation before running .NET custom action?

Hi, I'm using a VS 2008 Setup and Deployment project to deploy a mixed managed / unmanaged application. I've had trouble registering mixed-mode DLL's using the built-in registration property ("vsdraCOM" enumerated value of the "Register" property.) As a workaround, I've added a .NET custom install assembly (with a class that derives f...

How to use conditions in features in WiX?

Hello, I am trying to make simple windows intaller and I don't know how to deal with this. I have two features - feature1 and feature2. I want feature2 to be installed only if the user selected feature1 to be installed. So I tried: <Feature Id='core' Title='Core' Description='ØMQ 1.0.0 core functionality and C++ API' Level='1'> <Co...

how to use if rule in jquery

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...

Condition Binding Attribute Not Working?

I've been struggling with this code for some time now and can't seem to find any complete answers to my question. I've created a small sample to illustrate the problem: <ListView > <ListView.ItemsPanel> <ItemsPanelTemplate> <StackPanel Margin="0,0,20,0" IsItemsHost="True" /> </ItemsPanelTemplate> </ListView....

Reccomended thread layer to use for iPhone development?

I'm new to Objective C, and Mac development... It appears that I can use the Posix threads API in my app.. Is this the recommended way? Or is their some Apple API I should be using for mutexes, condition variables and threads instead? I should add that I'm developing for the iPhone. I'd like to add exactly what I'm trying to do. Basica...

What is the purpose of using WHERE 1=1 in SQL statements?

Possible Duplicates: Why would a sql query have where 1 = 1 Why would someone use WHERE 1=1 AND <conditions> in a SQL clause? I've seen that a lot in different query examples and it goes to probably all SQL engines. If there is a query that has no conditions defined people (and specially ORM frameworks) often add always-true ...

why can't conditional operator be used as a statement

Why can't the conditional operator be used as a statement? I would like to do something like: boolean isXyz = ...; ... isXyz ? doXyz() : doAbc(); where doXyz and doAbc are return void. Note that this is not the same as other operators, for example doXyz() + doAbc() intrinsically needs that doXyz and doAbc return a number-like someth...

Determine Which Part(s) of WHERE Statement Failed

Let's say I have a SQL statement like this that checks a user login: SELECT * FROM users WHERE username='[email protected]', password='abc123', expire_date>=NOW(); Is there a way in SQL to determine specifically which WHERE conditions fail, without having to separate each condition into its own query and test individually? In this sp...

switch statement in Jquery and List

Hi, I would like to know if my approach is efficient and correct. my code is not working though, I don't know why. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <html xmlns="http://www.w3.org/1999/xhtml"&gt; <head> <meta http-equiv="Content-Type" content="te...

Java: Math condition

Hello, Is there a simple way to do this if (1 < x && x < 3) { .... } I want something like this: if (1 < x < 3) { .... } I know that the code above is wrong but.... Thanks ...

Assembly language je jump function

Hello everyone! I am trying to find online the usage of the assembly language function "je". I read that je means jump if equal and that is exactly what I want. What is the actual usage of this function, or in other words, how to I type this function to check a value and jump if it is equal to something? Please let me know. BTW, I am u...

Rails Condition Statement Issue

Hi I have no idea why I am having problems with something so simple but this condition statement is just not working. @battalion = Battalion.find(params[:id]) @soldier = @battalion.soldiers(:conditions => ["seniorleader = ?", "No"]) This shows the array of Soldiers but doesn't reflect the condition I have set. I am sure I am doing...

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...

WIX ServiceInstall - Using comboBox to conditionally install service

Hi All, I have created a WIX setup script to allow the install of a Windows Service. I would like to give the user the ability to choose whether they would like to install under one of the standard accounts (Network Service, Local Service) or whether they would like to install under a user account with which they must supply a username...