Questions tagged [conditional-statements]

"In computer science, conditional statements, conditional expressions and conditional constructs are features of a programming language which perform different computations or actions depending on whether a programmer-specified boolean condition evaluates to true or false. Apart from the case of branch prediction, this is always achieved by selectively altering the control flow based on some condition." -- Wikipedia

Read on Wikipedia

19093 questions
4
votes
2 answers

XAML "Conditional" Binding

I have a DataTrigger attached to a style for TextBlock, defined as such:
flamebaud
  • 978
  • 1
  • 9
  • 26
4
votes
3 answers

Nested condition vs. return on unexpected result

Consider the two following coding-styles: Nested conditions: if(is_numeric($user_id)) { // .. do stuff if(is_valid_user($user_id)) { return foo($user_id); } else { return FALSE; } } else { return FALSE; } vs.…
Zar
  • 6,786
  • 8
  • 54
  • 76
4
votes
6 answers

Is the conditional "if(x)" different than "if(x == true)"?

I'm wondering what the core difference is between the conditional syntax below? if (something) { // do something } vs. if (something == true) { // do something } Are there any differences? Edit: I apologize. I made a typo when the question…
Codist
  • 1,198
  • 2
  • 11
  • 28
4
votes
7 answers

Strange php if statement problem

if($country == 224 || $country == 223 || $country == 39 && $zip == '' ){ $_SESSION['sess_msg'] = "Please enter a Valid zipcode"; header("location: $SITE_PATH?p=account.profile.name"); exit; } variable value -------- ----- $country …
JasonDavis
  • 48,204
  • 100
  • 318
  • 537
4
votes
3 answers

Sed with multiple criteria

I have 3 sed commands: sed -n 's/.*domain=\([^&]*\).*sdk_ver=\([^&]*\).*/\1 \2/p' inputfile > outputfile sed -n 's/.*sdk_version=\([^&]*\).*domain=\([^&]*\).*/\2 \1/p' inputfile > outputfile sed -n 's/.*domain=\([^&]*\).*sdk_version=\([^&]*\).*/\1…
user1536782
  • 97
  • 1
  • 2
  • 12
4
votes
1 answer

Open Google Maps InfoWindow based on certain criteria

I want to open a Google Maps InfoWindow based on whether or not one of my buildings is throwing a building alarm. The buildings I have the markers on all have alarm states (on or off), and if they are in alarm state, I am changing the color of the…
4
votes
3 answers

Adding a formula to a Gravity Forms form

Gravity forms allows for basic field calculations using merge tags, such as {Field 1:1} * {Field 2:2}, but I would like to use if/and/else statements to set a field value such as: if (and ({Field 1:1} = 200,{Field 2:2} = 1), 100, if (and ({Field…
Caroline Elisa
  • 1,246
  • 6
  • 18
  • 35
4
votes
1 answer

IE9 Browser modes and conditional comments

I'm using HTML Boilerplate document header which adds various classes to the tag for version of IE. When using IE9 (pressing F12) and changing the Browser Mode, I seem to remember this would always show the relevant browser (IE8/IE7 or IE7 when in…
4
votes
2 answers

Create a vector from sampling based on 2 conditions

I would like to to sample values from a vector s<-0:1440 to create a vector u so that the sum(u)=x while length(u)sum(u). Is there any way to brute force simulate numerous such u vectors? I would like to…
ECII
  • 10,297
  • 18
  • 80
  • 121
4
votes
4 answers

Fewer lines for switch statement?

I wonder if this …  inputs.keydown(function (e) { switch (e.keyCode) { case 13: //Enter case 16: //Shift case 17: //Ctrl case 18: //Alt case 19: //Pause/Break case 20: //Caps…
matt
  • 42,713
  • 103
  • 264
  • 397
4
votes
1 answer

Cabal: conditionally override a flag default value

Is there any way to rewrite either: flag llvm description: compile via LLVM default : if os(mingw32) False else True or flag llvm description: compile via LLVM default :…
Cetin Sert
  • 4,497
  • 5
  • 38
  • 76
4
votes
5 answers

Can I code CSS specifically for Mac browsers?

Site: http://clientfiles.priworks.com/lgmanagedportfolios/test/investment.html I have been working at this web page for a while now trying to get the left side of the first submenu link to line up with the left of the 1st parent/main menu link. I…
DevKev
  • 5,714
  • 6
  • 24
  • 29
4
votes
1 answer

Mix strings with numbers on Eval Expression of Breakpoints on Delphi

I'm using Delphi XE2. And I would like to able to log data using the Delphi Breakpoints. Ex: Format('%s:%d', [Name, Id]) When I try this, it doesn't recognizes Format. I didn't found any details on Delphi Help on how to do it. The big benefit of…
Code Rage
  • 555
  • 3
  • 9
4
votes
4 answers

?: Conditional Operator in LINQ not working as expected

I'm having problems with one of my LINQ queries, so I made a simplified version of it in LINQPad to help me. Problem is, I don't understand why it's still not doing what I think it should... var list = "1 2 3 4".Split(); var result =…
Marcus
  • 5,407
  • 3
  • 31
  • 54
4
votes
6 answers

SQL: selective subqueries

I'm having an SQL query (MSSQLSERVER) where I add columns to the resultset using subselects: SELECT P.name, (select count(*) from cars C where C.type = 'sports') AS sportscars, (select count(*) from cars C where C.type = 'family') AS…
Jela
  • 562
  • 1
  • 6
  • 20
1 2 3
99
100