condition

Makefile : contains string

The variable returns MINGW32_NT-5.1 or CYGWIN_NT-5.1. (yea, dot at the end) Need to compare that given var contains NT-5.1 positioned anywhere. Using cygwin and would like to be compatible with pretty much any *nix. ...

Conditionally Delete in Ant

I want to delete the directory if the property "delete-compiled-dir" is set to true. If the property is false then do not execute it. Right now I have <target name="deleted-after-compilation" depends="compile,jar"> <condition property="${delete-compiled-dir}" value="true"> <delete dir="${compilation-dir}" /> ...

MySQL where condition but not limited by it

Hello. I would like to run a query on my database like this: SELECT SUM( t1.value ) AS total1, SUM( t2.value ) AS total2, SUM( t3.value ) AS total3, SUM( t4.value ) AS total4 FROM pay1 t1, pay2 t2, pay3 t3, pay4 t4 WHERE t1.date = '2010-04-29' AND t2.date = '2010-04-29' AND t3.date = '2010-04-29' AND t4.date = '2010-04-29' I am genera...

How to compare two floating-point values in shell script

I had to do a division in shell script and the best way was: result1=`echo "scale=3; ($var1 / $total) * 100"| bc -l` result2=`echo "scale=3; ($var2 / $total) * 100"| bc -l` but I want to compare the values of $result1 and $result2 Using if test $result1 -lt $result2 or if [ $result1 -gt $result2 ] didn't work :( Any idea how to do t...

Wait on multiple condition variables on Linux without unnecessary sleeps?

I'm writing a latency sensitive app that in effect wants to wait on multiple condition variables at once. I've read before of several ways to get this functionality on Linux (apparently this is builtin on Windows), but none of them seem suitable for my app. The methods I know of are: Have one thread wait on each of the condition variab...

how avoids deadlock condition

Hi I try to write a program like a compiler.In this case I must simulate these codes of SQLPL(This one can be just for example).for example in command prompt i wana do these: c:\> sqlplus .... Enter User-Name:(here we must enter username) xxxx Enter password:(same up)yyyyy ... sql>(now i want to send my sql command to shell)prompt "rim...

What are the benefits of `while(condition) { //work }` and `do { //work } while(condition)`?

I found myself confronted with an interview question where the goal was to write a sorting algorithm that sorts an array of unsorted int values: int[] unsortedArray = { 9, 6, 3, 1, 5, 8, 4, 2, 7, 0 }; Now I googled and found out that there are so many sorting algorithms out there! Finally I could motivate myself to dig into Bubble So...

Common Lisp condition system for transfer of control

I'll admit right up front that the following is a pretty terrible description of what I want to do. Apologies in advance. Please ask questions to help me explain. :-) I've written ETLs (Extract, Transform, Load) in other languages that consist of individual operations that look something like: // in class CountOperation IEnumerable<...

Checking for empty variable in PHPTAL condition

In PHPTAL tal:condition can check is variable empty? Something like that: < tag tal:condition="var" >Some text< /tag > but the value of variable is like that: <?php $variable = ''; $Tpl->var = $variable; ?> And it's a problem 'cause PHPTAL that value '' interpreting like not empty value and condition return true. Next problem is u...

iPhone: Create a single UIView from multiple clicks

I'm making a partial overlay modal in my app with the code from “Semi-Modal (Transparent) Dialogs on the iPhone” at ramin.firoozye.com. In doing so, the button that calls the modal is still visible and clickable. I will hide this button when the modal spawns, but I want to be sure if the user clicks very quickly twice, a new modal doesn'...

Rails - Find Condition of two model fields

I'm trying to find the results of a model where it queries as the result of two conditions. I have a search tag that looks for Model.find(:all, :conditions => "name LIKE params[search]") but I'd like for the search to find all records where "name LIKE params[search] or description LIKE params[search] . Is there any way to add an ...

Conditionally install feature not working in Wix

Hi, I have a setup which I need to support on IIS6 and IIS7. For now Im using the built in IIS extensions for IIS6 like so: <Component Id="C_IISApplication" Guid="{9099909C-B770-4df2-BE08-E069A718B938}" > <iis:WebSite Id='TSIWSWebSite' Description='TSWeb' SiteId='*' Directory='INSTALLDIR'>...

Problem in a php if condition

I have a small problem. I access the site thru foro.php?id=74&mode=add or foro.php?id=74&mode=edit it works fine.. But when I add a colon, semicolon (; or :) to foro.php?id=74&mode=add it goes to the edit option foro.php?id=74&mode=add; foro.php?id=74&mode=add: foro.php?id=74&mode=add’ Below is my code <?php $numb=mysql_real_escape_...

Ways to Find a Race Condition

I have a bit of code with a race condition in it... I know that it is a race condition because it does not happen consistently, and it seems to happen more often on dual core machines. It never happens when I'm tracing. Although, there is a possibility that it could be a deadlock as well. By analyzing stages of completion of logs where ...

Shell command - condition based on output of command?

I'm trying to run some shell command if a string is not present in a text file. If I paste this line into the command line if gives me an error. if [ $(cat textfile.txt | grep "search string") -eq "" ]; then; echo "some string"; fi; Error: -bash: [: -eq: unary operator expected ...

what is the syntax for "or" inside an if statement?

I could probably use multiple else if statements, but is there a simpler and cleaner way to do an if (condition or othercondition..) in objective-c? ...

SQL Server - selecting a row doesn't return any NULL values. Why?

Hi. I've got the following SQL table: CREATE TABLE [dbo].[Test]( [TestID] [int] NOT NULL, [TestNum] [int] NULL, [TestReason] [varchar](50) NULL ) So TestNum an INT which allows NULL values, and I've inserted a whole lot of data into the table, of which some of the rows contain a NULL value for TestNum If I then run the fo...

WIX UI - Creating a "passwords don't match" label

I need my installer to accept a password, and so I've created a dialog on which users are prompted to enter their passwords twice (to avoid mistakes), however I'm having some trouble getting my "Your passwords don't match" label to appear and disappear at the correct times. This is what I have so far: <Control Id="Password" Type="Edit"...

Enable/Disable other elements based on selection

<select name="feature1"> <option value="1">Enable</option> <option value="0">Disable</option> </select> <input type="checkbox" name="feature2" /> <input type="checkbox" name="feature3" /> How do I disable 'feature2' and 'featured3' inputs when 'disable' in 'feature1' is selected? Thanks ...

Check time interval using SQL condition

I'm storing some intervals in the SQL, example: id INT from DATE to DATE How can I check, using only one condition (if possible) if a NEW interval conflict with a existing one? Examples: |-----------| (from 1 to 5) |-----------| (from 2 to 6) |--| (from 3 to 4) |--| (from 7 to 8) Every interval (in th...