FAQ Database Discussion Community


Switching between date format in a for loop; Python

python,date,if-statement,for-loop
The date in my data is stored in two different formats: Dienstag 31. Dezember 2013 and 30. Juni 2007 I wrote scripts to extract Year/Month/Day from both formats and store them in a list: for row in reader: line_count = line_count + 1 if row[1] == "DATE": pass else: date...

How to break if-else-if using C#

c#,if-statement
How do I break if-else-if.....Why its not working? its just checking all the conditions instead of performing the tasks. following is my code. I have checked it through breakpoints its moving to all conditions why it doesn't get stop after meeting the correct condition. even it is not going into...

How to make if statement that checks if multple listBoxes are empty or not?

c#,winforms,if-statement,listbox
How do I make an if statement that asks if multiple listBoxes are empty or not? This is what I have so far...is it possible to combine it into one single if statement? if (listBoxEmails.Items.Count < 1) { //Perform action } if (listBoxWebsites.Items.Count < 1) { //Perform action } if...

Python - Using a created list as a parameter

python,list,loops,if-statement,compare
When I run my code it tells me: Type Error: unorderable types: str() < float(). I can't figure out why it won't let me compare these two numbers. The list I am using is defined, and the numbers in it have been redefined as floats, so I'm not sure what...

Oracle regular expression REGEXP_LIKE for multiple columns

sql,regex,oracle,validation,if-statement
I want to validate TAX , NAME, TELEPHONE NO . Those are should be alpha-numeric.So used this method but in here i want to know can i do this same by short method in simply way without using so many "AND" s. IF REGEXP_LIKE(i.TAX, '^[A-Za-z0-9]+$') AND REGEXP_LIKE(i.NAME, '^[A-Za-z0-9]+$') AND REGEXP_LIKE(VarTelephone...

How to use AND operator for comparison in javascript?

javascript,html,string,if-statement,condition
I am trying to use AND condition to compare two conditions inside an if block. I am getting the website address using window.location.href function and then i am tring to compare them using match function. I am not able to figure out way i am not getting the desired result....

considering if, else if, else statements when writing code (java)

java,if-statement
I wrote a program that takes the sum and range of three integers in Java. my program has several if statements for finding the range (distance between biggest and lowest integer). I was wondering if my "if statements" are the most efficient way to go about finding the range, and...

>= not working, R [duplicate]

r,if-statement,double,logic
This question already has an answer here: Why are these numbers not equal? 3 answers I am running the code below. The function Ax returtns the value 1. But the ifelse statement does not recognize that Ax==1. I've tried making the output of the function double-precision and all numeric...

Float comparision in C [duplicate]

c,if-statement,compiler-errors,floating-point,floating-point-precision
This question already has an answer here: How dangerous is it to compare floating point values? 8 answers #include<stdio.h> int main() { float x = 0.6; if (x == 0.6) printf("IF"); else if (x == 0.6f) printf("ELSE IF"); else printf("ELSE"); } This code gives output ELSE IF #include<stdio.h> int...

Stop Prevent Default in else clause

if-statement,mobile,menu
Hello I have a mobile nav where some items have a subnav so I have set a preventDefault to stop these doing there normal actions and open the sub menu but some don't have a submenu ad now these don't work as normal. Any help would be great here is...

chained if-else not working (C++)

c++,if-statement,chained
I'm a beginner and am having trouble with my chained if-else statement. When I run the program, and I enter which item I select, it always outputs "Invalid entry.". Why isn't it executing the proper function when it is equal to it in the if-statement? Thank you, Don #include <iostream>...

using if statements in tableau on a contains function

if-statement,contains,tableau
Say I have city populations for each state / city in the united states. I want to mark each city with over 2 million population as a big city. then if a state contains a "big city", i want to mark that state as a "big state". I made a...

Python Reuse a Variable in the Else Block of an If-Else Statement

python,python-3.x,if-statement,condition
I'm currently working on a simple file transfer program in Python. I am having trouble with the function for prompting the user for the location of the folder to be copied. def getSrc(): if getSrc.has_been_called is False: source = askdirectory() getSrc.has_been_called = True return source else: return source getSrc.has_been_called =...

xslt condition output one by one

xml,function,xslt,if-statement,xpath
hope that someone has a suggestion about this: I need to have in each 'a', all the 'b' that have @n equal or bigger than the @n of the 'a' in which they are. I am using xslt 2.0 and Saxon-HE 9.6.0.5 XML source: <blabla> <a n="2"></a> <a n="6"></a> <b...

Is there a way to shorten my if(word.Contains(“tree”) ||word.Contains(“water”)||word.Contains(“sky”)) [duplicate]

c#,if-statement
This question already has an answer here: Using C# to check if string contains a string in string array 14 answers Pretty much what the title says, I got a big if-sentence with ~5Contains this is not nicely looking if I repeat this a few times, is there any...

how does Java handle && inside if statement

java,if-statement
I don't understand the reason why the follow java code throws a ArrayIndexOutofBound exception while (intArray[j] < intArray[j - 1] && j > 0) { int temp = intArray[j - 1]; intArray[j - 1] = intArray[j]; intArray[j] = temp; j--; } It appears that even if I AND(&&) both conditions,...

SyntaxError: Unexpected token if

javascript,if-statement,token
I'm currently learning javascript and I keep having this error!!! This is my script: var compare = function(choice1, choice2) if (choice1 === choice2) { return "The result is a tie!"; } else if (choice1 === "rock") if (choice2 === "scissors") { return "rock wins"; } else { return "paper wins";...

Python AND OR statements

python,if-statement,conditional
I am parsing text with Python and I have this final code to write sentences, but it does not work well: opt = child.get('desc') extent = child.get('extent') if opt == 'es': opt = "ESP:" elif opt == "la": opt = "LAT:" elif opt == "en": opt = "ENG:" if opt...

How to make my if statement output the correct printf C program

c,if-statement,compilation,generator
In the code below I have made a program that can make the amount of money you put in transfer into words. For example, "1234.56" turn into "One Thousand Two Hundred Thirty Four and ... 56 Cents". The thing is that when I try to input the amount "0.01" into...

Simple quiz won't wait for an answer

java,if-statement
I have been trying to make a simple quiz as part of an online exercise, I have 2 questions with an if statement that should only accept 1 of 3 possible outcomes, the correct answer, the wrong answer or an incorrect selection. My problem is, when the user makes and...

Chance of a conditional occurring in Swift: Xcode

xcode,swift,if-statement,conditional,percentage
I am quite new to Xcode and swift so sorry if this is a bad description. Is there a way that there is a chance of your conditional occurring so instead of it happening 100% of the time when the conditions are met, it only happens 50% of the time...

Replace the following query in sqlite

c#,sql-server,sqlite,if-statement,sqlite3
I have a sql server query as follows in a store procedure with parameters @firstId and @secondId IF @firstId = '' begin SELECT DISTINCT x, y = FROM t1 LEFT OUTER JOIN t2 ON t1.id = t2.id AND t2.id = @secondId ORDER BY t1.somecolumn END ELSE BEGIN SELECT DISTINCT x,...

if statement doesnt work as i would expect them in python [duplicate]

python,if-statement
This question already has an answer here: How do I test one variable against multiple values? 10 answers hey im doing the learn python the hard way thing and im stuck at exercise 36 where you are to build something yourself. i have following code i have been going...

if condition in try process

android,if-statement,try-catch
i have some problem when trying to implement condition in "try" process, the result always of "globalnidn" always isi , therefore i've checked in logcat and the result is fine. :( protected void onPostExecute(String data) { try { JSONObject jObject = new JSONObject(data); globalnidn = null; globalnidn = jObject.getString("nidn"); String...

Spreadsheet if else sum

excel,if-statement,spreadsheet,calc
I would appreciate some help writing a statement in a spreadsheet (Libreoffice). IF E4 contains "bought" then do the sum of I4-F4 ELSE / ELSEIF E4 contains "sold" do the sum of F4-I4. I have it partially working: if E4 contains "bought" the correct sum is displayed, but if E4...

Check if string contains non-alphanumeric except underscore

c#,if-statement,alphanumeric
I'm trying to write in if statement that runs if a string contains any non-alpahnumeric character with the exception of an underscore. This is what I have and I'm trying to figure a simple way to add the exception for underscore but I'm having difficulty. (where key is a string)....

R: recursive function to give groups of consecutive numbers

r,if-statement,recursion,vector,integer
Given a sorted vector x: x <- c(1,2,4,6,7,10,11,12,15) I am trying to write a small function that will yield a similar sized vector y giving the last consecutive integer in order to group consecutive numbers. In my case it is (defining groups 2, 4, 7, 12 and 15): > y...

using if else with codeigniter return value

php,codeigniter,if-statement
I am using codeigniter framework for one of my inventory management systems. I prefer using php due to its variable functionality which makes things easier. So I am trying to get the username from session and then check the database for the level of the user and accordingly he should...

The program after if statement is not exectuing

python,if-statement
I have a problem with escaping from if, my code looks more or less like this in python: if answear == "Yes": do something pylab.show() if anwear == "No": do something pylab.show() answear2= input("How are you?") print ("I'm here") The problem is that is statement works nicely but after showing...

PHP - If a string or variable begins with a vowel

php,if-statement
I did a if thing to check if the variable only had aplha caracter but I also want to check if the variable strated with a vowel. if (ctype_alpha($original)) { print "oké"; } else { print "pas oké"; } If there isn't any specific function, how could I know ?...

Print all non-matching items in Perl

regex,perl,if-statement,matching
I have a perl script that compares text from two files. The files on most days should be exactly the same, but if for some reason some of the text in the file changes I want the script to print out all the text that is not exactly the same...

Check if VB.net dataset table exists

vb.net,if-statement,dataset
I have the following code to check if my table exists before proceeding If ds.Tables(3).Rows.Count = 0 Then MsgBox("Nothing!!!!") Else DataGridView1.DataSource = ds.Tables(3) The trouble is I keep getting the error "Cannot find table 3." How in VB can I check if the table exists, rather than my application erroring...

IF-Statement Combination with mb_strlen doesn't work [closed]

php,if-statement
I have a form with following if-statement's but it doesn't work. The First verification "If empty" does work but not the second one with mb_strlen, why? That's my PHP-Code: elseif(empty($_POST['project_title']) OR (mb_strlen($_POST['project_title'], 'UTF-8') <= 3)){ echo "Please correct the Project Title";} I don't get also any error. Do I have...

Several nested if conditions

c#,if-statement
I have five conditions that I have to check (i.e does the user want to search using this field or not). There are four combo boxes and one text field. The user can search using any field or multiple fields as they please. To check which field the user selected...

How do I format the logic for 3 conditions and use a previous condition as well?

java,loops,if-statement,while-loop,logic
NOT ASKING FOR ANYONE TO WRITE THE PROGRAM FOR ME I am having trouble understanding how to setup the logic for a program given these following conditions: For every day late up to and including 7 days, the late fee is $0.10/day After 7 days, for every day late up...

Rails Devise Routes: If user signed in, point to index. Else, point to new user session

ruby-on-rails,ruby,if-statement,devise,routes
Pretty simple question, but I can't seem to find the answer with a good ole fashioned Google. The error: undefined method `user_signed_in?' for #<ActionDispatch::Routing::Mapper:0x007fc6369320e8> (NoMethodError) Server won't even start. My code: Rails.application.routes.draw do devise_for :users, :path_prefix => 'u' resources :users devise_scope :user do get "login", to: "devise/sessions#new", as: :login get...

Javascript if (window.location.href) adding two urls

javascript,html,css,if-statement
Very simple question but can't find the answer. Can you put two url's inside if (window.location.href here is mine: if (window.location.href == 'http://example.example.com/support/default.asp') { } I need to add a second link... so i only want a div to load from that page and one more page....

Javascript Replace function not working on first instance

javascript,jquery,string,if-statement,replace
I am currently trying to make a list, using javascript and jquery that returns a string of keywords as shown here: keyword+keyword+keyword+keyword I am attempting to do this by adding a class 'active' when a keyword is clicked as shown in the code below, then checking whether it is active,...

Preventing the user from entering identical elements(within a malfunctioning try catch)

java,if-statement,arraylist,try-catch
So the following code is like a simple game,where the objective to to guess the correct numbers(which are 1 to 5).Anything else is incorrect and the user is given a warning message if they enter similar numbers.The comments would explain the loops and variables declared. The only problem I have...

javascript - check what table is in use

javascript,jquery,if-statement,jquery-plugins
I have got two tables, and only one javascript function associated to both. I would like to create a case differentiation in order to run different methods through an IF statement depending on which table is selected. This is my code: <table id="table1" notip="true" class="dataTable no-footer" ...> <thead></thead> <tbody> <tr><td></td></tr>...

Jquery target div inside clicked

jquery,if-statement,html-lists,parent,target
I am trying to make a drop down menu which using :hover works great on desktops and android, but breaks on iPad. Because of this I am swapping :hover for jquery. The below does just what I need...almost. var down = false; $("li").click(function() { if (down == false) { $(".dropdown").css("height",...

python if statement inside for syntax error

python,if-statement,syntax-error
I wrote some code but I can't get why the pyscripter is telling a syntax error in the if statement: #search for 9 elements file_writer = open('C:\\PythonProject2\\commands_NUM.txt','w') for item in data_indices: flag= search_object(item,data,obj_value_min,obj_value_max) if flag = True:###ERROR file_writer.write('frame0: ' + str(item[0]+1)+' ' + str(item[1]+1) + '\n') ##Here is the syntax...

How to deal with NA when using lappy in R

r,if-statement,na
I have a data frame err consisting of 796 rows and 54432 columns I have to check the columns that have values not exceeding 20 and -20. This is my approach: do.call(cbind, (lapply(err, function(x) if((all(x<20) & all(x>-20))) return(x) ))) I Have NA values in all of the columns and after...

If/else problems in python

python,if-statement
Ok, I'm gonna explain this as best I can. I am trying to make an if/else statement in python that basically informs the user if they put in the right age based on raw input, but I keep getting an error in terms of my if statement. Can I get...

How to close the process from class code?

if-statement,axapta,x++,dynamics-ax-2012,close
I call a class form MyForm. In my class I have a if-else statements. I want to close all process, I need a command look-like element.close(); Example, my code: if (_condition a_) { //operations class; } if(_condition b_) { //abort all, and close all; } How should I do if...

If and only if in vb.net 4?

vb.net,if-statement,.net-4.0
IIF seems to be unavailable in .net 4, do we have a replacement? IIf(condition = 0, True, False) Would be a simple if statement a good replacement?...

Swift If program

swift,if-statement,random
Still a beginner with just playing around with some basic functions in swift. Can someone tell me what is wrong with this code? import UIKit var guessInt: Int var randomNum = arc4random_uniform(10) if Int(randomNum) == guessInt { println ("correct") } else { println; "no, the number is not. guess again"...

Simplify multiple if-else statements for unit testing

java,if-statement
I am writing some java code to check multiple conditions by if-else. The code is working properly but it is hard to do unit test. reads lines that contains keyword conditionOne, conditionTwo or other keywords. hasConditionOneEnabled and hasConditionTwoEnabled are boolean values. My real code has more else if statements than...

Problems with control flow structures using strings

java,if-statement,switch-statement,control
Below is method that asks for a medium that is either air, water, or steel. If what is entered isn't one of these, the programs ends. If it is a valid medium, it asks for a distance it will travel and calculates the time through each medium. The problem I...

SAS else if clause confusion

if-statement,sas
I'm running the following code: data new; set old; if visits=. then band='Poor'; else if visits=1 or visits=2 then band='Low'; else band='High'; run; My confusion is when the else if statement is changed to: else if visits=1 or 2 then band='Low'; Why does the value Low appear as the band...

passing a workbook Name into a For Loop C#

c#,excel,if-statement
So I am doing a few For loops that iterate through different variable changes imported from a template, a SQL script run, data is dumped, loop to next SQL script, etc, and this is done multiple times using the same template file (which at the end of the query dumps...

How to add a class to an element that is outside of your onclick element

javascript,jquery,if-statement,onclick
I need some help with some If statement. I have this div <div id="features-dots"> <ul> <a href="#"><li class="one"></li></a> <a href="#"><li class="two"></li></a> <a href="#"><li class="three"></li></a> </ul> </div> and <div class="feature_thumb"> <a class="feature_thumb" id="one" onclick="return false;"></a> </div> <div class="feature_thumb"> <a class="feature_thumb" id="two" onclick="return...

php else statement not working (closed)

php,if-statement
I have code like this function change_lang($lang,$page,$city) { $chglang = []; if($page == 'Province' || 'Provinsi') { if($lang == 'en') { $query = $this->db->query ("SELECT slugId AS slug FROM `navbar` WHERE slugEn='$city'"); } else { $query = $this->db->query ("SELECT slugEn AS slug FROM `navbar` WHERE slugId='$city'"); } foreach ($query->result_array() as...

Java equivalent of C#'s 'Enumerable.Any'

java,if-statement
In C# there is a way of reducing the length of an if-statement by using Enumerable.Any to check if elements in a sequence satisfy a condition (https://msdn.microsoft.com/en-us/library/vstudio/bb534972%28v=vs.100%29.aspx). For example Instead of: If ( string.Contains(">") || string.Contains("<") || string.Contains("&") || string.Contains("l") || string.Contains("p") ) We can use if (new [] {...

Display only values containing specific word in array

php,arrays,json,string,if-statement
Right now I am working on a search function for my json decoded results. The code that I got looks like this: <?php foreach($soeg_decoded as $key => $val){ $value = $val["Value"]; $seotitle = $val["SEOTitle"]; $text = $val["Text"]; echo '<tr><td>' . $value . '</td><td>' . $seotitle . '</td><td>' . $text ....

Using ifelse Within apply

r,if-statement,nested,data.frame,apply
I am trying to make a new column in my dataset give a single output for each and every row, depending on the inputs from pre-existing columns. In this output column, I desire "NA" if any of the input vales in a given row are "0". Otherwise (if none of...

Combining multiple for loops into one using the OR operator

c++,if-statement,for-loop
This is probably a simple question, but I can't get it to work. I've searched and have tried all the suggestions people gave for the OR operator ||, but my code just won't properly use it. So here's what I've got: This part of my code looks at a vector...

[: : integer expression expected

bash,if-statement,integer
COUNTER=0 let COUNTER=COUNTER+1 count=`ssh -i /var/www/.ssh/id_rsa_root -o stricthostkeychecking=no $host $cmd` count1=`echo $count | awk '{print $4}'` printf "count1 : $count1\n" result1=${count1/.*} if [ "$result1" -ge "0" ]; then echo $host else echo $host exit fi If the value of $result1 is INTEGER and greater than zero, it'll goto IF loop...

What is the best way to rewrite this repeated if statement?

php,if-statement
I'm thinking there is an easier way to write this code, but not sure on what approach to take. Basically, I want to check if each variable exists, and if so - add the appropriate markup to the page. Any suggestions would be great. <?php $words = get_field('words'); $photography =...

Get actual path from path with wildcard

powershell,if-statement
When using Test-Path in an if statement, I am looking to get the path that the if statement succeeds with. For example, these files exist in C: C:\Test6_1_15.txt C:\Test6_2_15.txt C:\Test6_3_15.txt C:\Test6_4_15.txt what do I do in the "then" branch? $Path = "C:\Test6_*_15.txt" if (Test-Path $Path) { # if test passes...

PostgreSQL conditional statement

sql,postgresql,if-statement
I need to implement a conditional SELECT statement based on the result of another statement. I don't want to create a function for this purpose, but simply using conditional SELECT. My unsuccessful approach looks as below: DO $do$ BEGIN IF SELECT count(*) FROM table1 < 1 THEN SELECT * FROM...

Complex if clause imbrication

java,if-statement
While I was looking for code snippets online, I came across this weird code if(filename!=null) if(filename.exists()) saveFile(filename); else quit(); Why can this code compile when first "if" does not contain anything?...

Time's Tables Quiz (Error)

c,if-statement,syntax-error,expression
HELP NEEDED :D So trying to embark on making a time's tables quiz for my brother.Very new to coding so trying to do it as simple as possible but really stuck. Any help would be awesome Basically I keep getting this error [ In function 'main': Line 17: error: expected...

Rails keeps ignoring an IF statement inside the view

ruby-on-rails,ruby,if-statement,flags
I am writing an application where I want to list blog posts according to date they were created on the main index page. So lets say if I have 10 blog posts that were created today I would want to have smth like this come on the index page of...

The if statement doesn't work for false in php

php,if-statement
When trying to get familiar with if statement in PHP, this happened. First time i tried this code below. if(true) {echo 'true';} else {echo 'false';} And the output was true when the condition is true. Again, when the condition is false (if(false)) it echos false. But i tried the same,...

MVC View change specified row bgcolor

asp.net-mvc,if-statement,html-table,asp.net-mvc-views
In my MVC view, I am displaying list of data from my model in a table as shown below. How to make a specified row to change color when one of the field satisfy certain condition within my if-else statement? It does not seems like I can add a jquery...

How does this code print odd and even?

c,if-statement,macros,logic
#define MACRO(num, str) {\ printf("%d", num);\ printf(" is");\ printf(" %s number", str);\ printf("\n");\ } int main(void) { int num; printf("Enter a number: "); scanf("%d", &num); if (num & 1) { MACRO(num, "Odd"); } else { MACRO(num, "Even"); } return 0; } Please explain the above code (if/else condition and how...

If statement for search field in Rails

jquery,ruby-on-rails,search,if-statement
I have a blog site and recently added a search bar for visitors to browse through blog posts. When used, all of the posts go away in the directory and only those which return via the search appear. In order to show the general directory and view all, I would...

Convert a string to a double for a if clause

android,string,if-statement,double
I'm trying to convert a string to a double, so I can use the double to compare it with another one, to make the result green if it's the same or red when not. The first method is: public void getCords(View view) { double latitude; double longitude; latitude = 1.00;...

jQuery - clearInterval seems not to work

jquery,if-statement,intervals,clearinterval
Long story short: If the interval count exceeds 5 the code should clear the interval, stopping it from executing the function every second. But this doesn't seem to work. HTML <div id='feedback'></div> JavaScript / jQuery window.intervalcount = 0; var interval = setInterval(function () { intervalcount += 1; $("#feedback").text(intervalcount); }, 1000);...

second else if stament is NOT working properly

bash,if-statement
My second "else if" is not working. I cannot download the file if the file is not there. I do not know what I'm doing wrong here. #!/bin/bash # upper case file_upper_case=/root/MASTER.txt # lower case file_lower_case=/root/master.txt if [ -e "$file_upper_case" ]; then echo "File is upper-case" echo "Changed to lower_case"...

if compare doesn't work in php

php,if-statement,compare
I have a problem with a comparation. I execute this code after execute nmap and saving the pid in the database: include("classes/database.php"); //conection to database $selectActual = "SELECT * from InfActual"; $resultActual = $conn->query($selectActual); if ($resultActual->num_rows > 0) { while ($rowActual = $resultActual->fetch_assoc()) { echo "pid in DB: " ....

SQL Syntax error #1064 cursors (mysql)?

mysql,sql,if-statement,stored-procedures,cursor
So my procedure looks something like this: OPEN tstamp_cursor; get_timestamp: LOOP FETCH tstamp_cursor INTO cSID, ctstamp; IF finished = 1 THEN LEAVE get_timestamp ; END IF; SET @MID = 0; SET @MX = 0; SET @MY = 0; SET @MT = 0; SELECT @MID:=m.vID, @MX:=m.x , @MY:=m.y , @MT:=m.timestamp FROM...

Hiding #DIV/0! Errors Using IF and COUNTIF in Excel 2010

excel,vba,if-statement
I'm working on a tracking sheet for quality reviews of work completed. I have a list of criteria to be met for which the entry can be either Y or N, or X for not applicable. Each month a number of these reviews will be done on each person. In...

Matched data inside select supposed to selected by default

laravel,if-statement,laravel-4,foreach,blade
I have a database that contains project_development and developer. I want to make an edit form for the project_development that has select with option from developer table. when the data matches, the current option will be selected. It works fine on other select without the foreach loop statement. <select class="form-control"...

Jquery, Javascript click && value

javascript,jquery,if-statement,click,int
how do I check inside jquery if a button is clicked and if the variable test has an integer of 1? I have done this so far. $(".bx-next").click(function() && (test == 1){ $("#step_1").text("Hello world!"); }); ...

Stopping condition on a recursive function - Haskell

string,function,haskell,if-statement,recursion
So, I have this function which aims to align the text on the left without cutting words(only white spaces). However my problem is that I cannot find a stopping condition of the function and it goes infinitely. f n "" = "" --weak condition f n s = if n...

jQuery/Javascript get classes of multiple elements to show an element with this class

javascript,jquery,class,if-statement,jquery-selectors
I'm struggling with a jQuery live search. First of all the live search update with the following code works. //live search function function live_search(list) { $("#search") .change( function () { //getting search value var searchtext = $(this).val(); if(searchtext) { //finding If content matches with searck keyword $matches = $(list).find('a:Contains(' +...

How to make nested IF statements neater

python,if-statement
This question could be asked in a language independent way but I'm asking in the context of python since different languages will have different nuances. I recognize that this is similar to this question but I think mine is different in that I'm asking about a case where putting the...

How do I check whether a file or file directory exist in bash?

bash,if-statement
I currently have this bash script (which is located in my home directory, i.e., /home/fusion809/ and I am running it as root as it's necessary for the icon copying lines): cd /home/fusion809/Pictures/Icon* declare -a A={Arch,Debian,Fedora,Mageia,Manjaro,OpenSUSE} declare -a B={Adwaita,Faenza,gnome,Humanity} for i in $A; do for j in $B; do if test...

My batch files if else statement isn't working

batch-file,if-statement
So I have created a file that works and when testing it without the if/else statement. When I put in this in a if statement it doesn't work at all though, is my syntax wrong or what? Thanks. @echo off set /p id= Folder Name: set /p yn= Subfolders? (y/n):...

Getting my program to go back to the “top” (if statement) (Java)

java,if-statement,while-loop,leap-year
I have a program to calculate leap year, however, it only works past about the year 1750 so I want my user to only be able to input numbers past 1750. System.out.println("Enter a year after 1750:"); leapYear = in.nextInt(); if(leapYear<1750){ System.out.println("You have entered a year before 1750, please try again...

Why does my nested for-if loops load much slonger when I dont nest this? And can I possibly fix this?

c#,excel,if-statement,for-loop,nested
Sorry if the question if a bit vague, but the code is very complicated and I hope you will have the right eye to see and understand it :) I will show 2 sort codes. The codes just read an excel sheet and depending on the text it contains, it...

didBeginContact logic OSX swift

osx,swift,if-statement,logic,collisions
I am having some trouble with the logic inside of didBeginContact on an OSX game i'm creating. It is written in swift, here is what the code currently is: func didBeginContact(contact: SKPhysicsContact) { let collision: UInt32 = contact.bodyA.categoryBitMask | contact.bodyB.categoryBitMask if collision == PhysicsCategory.player | PhysicsCategory.wall { } else if...

c# nested if/else in a for loop

c#,if-statement,for-loop
I have a nested if/else statement in a for loop to determine whether or a a value is valid with an array value. It returns all values just fine, however if the IF is correct, it still does the else an additional three times. I thought once it was equal...

Error w/declaration on else statement (C++)

c++,if-statement,declaration
#include <iostream> using namespace std; // Range of numbers, handles input in which the first number is smaller than the second. int main() { int max = 10; int min = 0; while(cin >> min) { if(min<max) { ++min; cout << "The number inputted is well in the RANGE: "...

pulling and comparing dates in excel

excel,vba,if-statement,excel-formula,excel-match
For example: On my first tab Last visit, I have columns, Customer Name, Customer # and Scheduled date On my second tab, All visits I have Customer Name, Customer #, and Visit Dates. Now, this tab shows all of the visit dates (even the last one that is on Last...

Have an if statement look ONLY at the first word in a string [duplicate]

c++,string,if-statement,vector
This question already has an answer here: how to check string start in C++ 9 answers I have a vector composed of strings, some strings have single words, some have multiple words, some have numbers, etc. I have a code that deletes elements of the vector IF the entire...

How do I get my logic in this Java program to make my loop work?

java,if-statement,while-loop,int,logic
I've made this java program to find the two smallest integers as inputted by the user. I think I'm pretty much just about there except there is one issue with my logic. I'm not sure what to set values: int min, min2; to where the rest of my program would...

Why does my program give me the excess output? C program

c,if-statement,generator,money
I've made a program that is a cheque generator. Whatever amount you input in the scanf will output in words. For example if I were to to input "1234.56" My output will be "One Thousand Two Hundred Thirty Four Dollars and ... 56 Cents", or if I wanted to input...

Time complexity of if-else statements in a for loop

if-statement,for-loop,time-complexity,asymptotic-complexity
Let A[1, …, n] be an array storing a bit (1 or 0) at each location, and f(m) is a function whose time complexity is θ(m). Consider the following program fragment written in a C like language: Case 1 :- counter = 0; for (i = 1; i < =...

Exit Sub within nested if statements not working

excel,vba,if-statement
I'm trying to write some VBA code and I have almost everything working pretty well. I just need a little help with a part. Here is my code: 'input if supervisor=fill in supervisor missing If UserForm1.superbox.Text = "Fill In Supervisor" Then If UserForm1.fillbox.Text = "(Fill In Supervisor)" or UserForm1.fillbox.Text =...

Jenkins Flexible Publish plugin if else condition

if-statement,jenkins,jenkins-plugins
I am using the flexible publish plugin for jenkins and found it very useful. My goal is to pass a set of predefined parameters from a job to trigger another downstream job. The downstream job performs an action based on the string match evaluation. But if i dont pass the...

Reduce the if-statement itself

c#,if-statement
This is my if-statement at the moment: if (excel_getValue("A" + i) == "" && excel_getValue("A" + (i + 1)) == "" && excel_getValue("A" + (i + 2)) == "" && excel_getValue("A" + (i + 3)) == "" && excel_getValue("A" + (i + 4)) == "" && excel_getValue("A" + (i +...

Javascript % operator in IF statement

javascript,if-statement
I'm trying to debug some pre-existing JS code and I can't work out what exactly this line of code does, can someone help if(value % 7 == 0){...} ...

Excel IF AND OR condition together

excel,if-statement,condition
I am trying to use this formula in excel but am getting an error. Can someone please help? =IF(OR(AND(B2>=Sheet3!$B$4,B2<=Sheet3!$C$4),AND(B2>=Sheet3!B6,B2<=Sheet3!C6))),"Blue","Grey") Programmatically, I am trying to get this: If((a>x && a<y) || (a>x1 && a<y1)){ Blue } else { Grey } ...

Lazy functions evaluation in swift

ios,swift,if-statement,functional-programming,lazy-evaluation
Wondering is it possible to evaluate a simple if statement lazily. Below is an example that will print "this is foo" and "this is bar", but I really want to make it print only the first string: func foo() { println("this is foo") } func bar() { println("this is bar")...

Swift won't allow me to use `!=`

ios,swift,if-statement,null
Currently trying to check if three values, that I just converted from Strings to doubles, are nil from the UITextFields aValue, bValue, and cValue. I don't get a compile error from these variables until the if statement at the bottom of the code block (shown below) where it causes a...

Comparing cell contents against string in Excel

string,excel,if-statement,comparison
Following is my table file:*.css file:*.csS file:*.PDF file:*.PDF file:*.ppt file:*.xls file:*.xls file:*.doc file:*.doc file:*.CFM file:*.dot file:*.cfc file:*.CFM file:*.CFC file:*.cfc file:*.DOC I need a formula to populate the H column with True or False if it finds column G in column F (exact case). I used following but nothing seems to...

Java dice roll with unexpected random number

java,if-statement
I've written a simple Java program to display the results of 20 dice rolls on the console. The results I'm getting are listed below: 3 1 [email protected] 1 5 4 1 [email protected] 1 [email protected] [email protected] 1 6 [email protected] 1 [email protected] [email protected] 1 2 3 3 When I ran it for...