conditional

XSL - Does evaluating conditional expressions "shortcut"?

Given an XSL 'If' statement: <xsl:if test="a = 'some value' and b = 'another value'"> If a does not equal 'some value', is the value of b still checked? (As if the first test is false, the only outcome of the and is false.) This is what languages like C# do - I was wondering if the same goes in XSL. Does it depend on the engine/parser...

How to show conditional data in views in MVC frameworks?

How do people generally handle conditional statements in MVC frameworks For some of my pages (made under Kohana) I want the user to have more options depending on whether they are logged in or not, and whether the profile is their own profile for example. From your own experience, do you create separate views, empty variables, do the l...

Why would a language NOT use Short-circuit evaluation?

Why would a language NOT use Short-circuit evaluation? Are there any benefits of not using it? I see that it could lead to some performances issues... is that true? Why? Related question : Benefits of using short-circuit evaluation ...

Problem with conditional databinding

hi guyz. i ve been strugling to find some way to do my required conditional binding, but i am lost :s i want to use Eval("products_image") in conditional binding in such a way that if product_image exists in images directory then its ok, otherwise it should display "noimage.jpg" i tried to do it this way: <%# (File.Exists(("ProductI...

Conditional Joins in LINQ

I have a parent child table relationship. In the example below Foo has a FooID and a nullable ParentFooID that points to a parent record. The Bar table is always linked to the parent record. This is the SQL I use to get the result. Select * from Foo f JOIN Bar b ON b.FooID = CASE WHEN f.ParentFooID is null TH...

Is it acceptable to only use the 'else' portion of an 'if-else' statement?

Sometimes, I feel like it is easier to check if all of the conditions are true, but then only handle the "other" situation. I guess I sometimes feel that it is easier to know that something is valid, and assume all other cases are not valid. For example, let's say that we only really care about when there is something wrong: object va...

BASH: Does it support conditional variables like var="test"?"1":"2"

I am new to bash but have done lots of PHP, and Javascript. Is there some sort of equivilent to this PHP? $default = 10; $var = (!$var) ? $default : $var; Thanks ...

My conditional css stylesheets for IE work when I test the pages locally but are not recognized once I upload the pages to my website

Hi, I'm using the IE recognized conditional statement to use an IE specific stylesheet for IE browsers: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt; <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>Touringhouse</title> <link type="text/css" rel="st...

Hiding site actions menu in moss depending on page

I am trying to hide the site actions menu from certain pages with our moss enviroment, specifically non-publishing pages. I was looking to use the SPSecurityTrimmedControl to achieve it, so in my masterpage I have: <Sharepoint:SPSecurityTrimmedControl runat="server" Permissions="ApproveItems"> <PublishingSiteAction:SiteActionMenu runat...

Testing for an empty iterator in a Python for... loop

The code below is based on this recipe. However, the key point of the recipe - that it provides a way to break out of the iteration on an iterator if the iterator is empty - doesn't seem to work here, instead behaving in the following undesired ways: If get_yes_no_answer() == False and there are two or more items left in the iterator, ...

Rails - validates_associated with an :if condition

I am running into an issue when trying to apply an :if condition to a validates_associated validation. The if condition works for validates_presence_of, but not for validates_associated, and the form (with two models in it) works correctly, except that the validation still returns an error, regardless of whether the if condition is true ...

In .NET, which is best, mystring.Length == 0 or mystring == string.Empty ?

Possible Duplicate: Checking for string contents? string Length Vs Empty String In .NET, which is best, if (mystring.Length == 0) or if (mystring == string.Empty) It seems that these would have the same effect, but which would be best behind the scenes? ...

Declaring and initializing a variable in a Conditional or Control statement in C++

In Stroustrup's The C++ Programming Language: Special Edition (3rd Ed), Stroustrup writes that the declaration and initialization of variables in the conditionals of control statements is not only allowed, but encouraged. He writes that he encourages it because it reduces the scope of the variables to only the scope that they are requir...

Java - Creating a string by selecting certain numbers from within a text file

I have a .txt file that has numbers 1-31 in it called numbers. I've set up a scanner like this: cardCreator = new Scanner (new File ("numbers")); After this, I'm kind of confused on which methods I could use. I want to set up a conditional statement that will go through numbers, evaluate each line (or numbers 1-31), and includ...

Joins in conditional statement in SQL Query

I have scenario like, I need to add my join in conditional e.g. When value is 1 then inner join to table a and if value 2 then inner join to table below is my sample query and I am getting error Incorrect syntax near the keyword 'inner' DECLARE @i INT=1 select name from emp if(@i=1) begin inner join a on a.ID=emp.ID end else if(@i=1)...

How to check if a variable has any value from a given set?

How can I check if a condition passes multiple values Example: if(number == 1,2,3) I know that commas don't work. EDIT: Thanks! ...

How can I write an .htaccess that will rewrite differently based on the request url?

I would like to have one .htaccess file that can rewrite correctly on both my localhost development environment and on my hosted production site. Right now I have to keep two separate file copies for every site I work on. I would like to be able to synchronize the two sites without blowing away either one of their .htaccess files. Belo...

Carrying out a jquery command based on conditional css style?

I want to carry out two different functions based on the height of a div. How would I write out a conditional that checks the style before deciding? ...

Haskell Conditionals

Hi, I'm having some difficulty integrating && within Guards eg: something :: Char -> Int something k | ord k >= 77 && ord k <= 98 = 8 | otherwise = 88 How the heck can i achieve the above without setting off an error? Cheers. ...

Alternative conditional syntax (if-else) failing on PHP 5.3.0 (xampp)

Hello, I recently upgraded to xampp v1.7.2 which dumped PHP 5.3 on me. Along with that all my httpd.confs and php.ini's got wiped out (I had taken it for granted that this release will be an upgrade like all the earlier xampp releases). Anyway, it took me a while to reconfigure all the services - but now I've run into a funny problem....