for-loop

Label in PyQt4 GUI not updating with every loop of FOR loop

I'm having a problem, where I wish to run several command line functions from a python program using a GUI. I don't know if my problem is specific to PyQt4 or if it has to do with my bad use of python code. What I wish to do is have a label on my GUI change its text value to inform the user which command is being executed. My problem h...

going reverse in a for loop?

Hello there, Basically i got this for loop and i want the number inputed (eg. 123) to be printed out in reverse, so "321". so far it works fine and prints out the correct order when the for loop is for(i = 0; i<len ; i++) but i get an error when i try to print it in reverse?. Whats going wrong? #include <stdio.h> #include <string.h>...

How to increment variable names/Is this a bad idea

In Python, if I were to have a user input the number X, and then the program enters a for loop in which the user inputs X values, is there a way/is it a bad idea to have variable names automatically increment? ie: user inputs '6' value_1 = ... value_2 = ... value_3 = ... value_4 = ... value_5 = ... value_6 = ...

App crashes often in a for-loop

Hello, my app crashes often in this for-loop: for (int a = 0; a <= 20; a++) { NSString * foo = [[NSString alloc]initWithString:[[newsStories objectAtIndex:arc4random() % [newsStories count]] objectForKey:@"title"]]; foo = [foo stringByReplacingOccurrencesOfString:@"’" withString:@""]; foo = [[foo componentsSepara...

for cycle not works allright

Hello. I call addNotify() method in class that I posted here. The problem is, that when I call addNotify() as it is in the code, setKeys(objs) do nothing. Nothing appears in my explorer of running app. But when I call addNotify()without loop(for int....), and add only one item to ArrayList, it shows that one item correctly. Does anybod...

Excel formula for variable fields

I am looking for a simple formula to do the calculation on two fields that are variable, for e.g., c1 has 100 and c3 has 150 and I want to calculate an increase/decrease percentage, but the trick is the cell values change every month. How do I put the formula to cater for such variation. Appreciate your help. Regards ...

Using forloop.counter value as list index in a Django template

Hi, in my Django 1.1.1 application I've got a function in the view that returns to his template a range of numbers and a list of lists of items, for example: ... data=[[item1 , item2, item3], [item4, item5, item6], [item7, item8, item9]] return render_to_response('page.html', {'data':data, 'cycle':range(0,len(data)-1]) Inside the...

question about select() and range of for loop to read sockets

Just a quick question about using select(). I'm using select() to read from multiple sockets. When I looked up examples on how to use select(), a lot of tutorials showed going through for loops and checking for FD_ISSET. The problem I have with those tutorials is that the for loop starts from i = 0. and checks if the bit has been set ...

breaking out of for loop when running a function inside a for loop in R

I'm embarrassed that I'm asking this question, but here I go: Suppose you have the following function foo. When I'm running a for loop, I'd like it to skip the remainder of foo when foo initially returns the value of 0. However, break doesn't work when it's inside a function. As it's currently written, I get an error message, no lo...

BASH statements execute alone but return "no such file" in for loop.

Another one I can't find an answer for, and it feels like I've gone mad. I have a BASH script using a for loop to run a complex command (many protein sequence alignments) on a lot of files (~5000). The loop produces statements that will execute when given alone (i.e. copy-pasted from the error message to the command prompt), but which r...

For Loop Question?

I'm programming an app for the iPhone. I'm not very good with loops just yet. How do I shorten this code into a for loop? if(CGRectContainsRect([space1 frame], [box frame])){ space1.image = [UIImage imageNamed:@"box.png"]; } else if(CGRectContainsRect([space2 frame], [box frame])){ space2.image = [UIImage imageNamed:@"box.png...

How to iterate loop inside a string searching for any word aftera fixed keyword?

Suppose I have a sting as "PHP Paddy,PHP Pranav,PHP Parth", now i have a count as 3,now how should I iterate loop in the string aiming on string after "PHP " to display the all the names? Alright This is the string "BEGIN IF (NEW.name != OLD.name) THEN INSERT INTO jos_menuaudit set menuid=OLD.id, oldvalue = OLD.name, newvalue = NEW.name...

is it possible to dynamically set the level of for loop nesting

I'm working out an algorithm to get permutations like 123 132 213 231 312 321 I'm doing it using nested foreach loops. for (..) { for(..) { for(..) { echo $i . $j . $k . "<br />"; } } } Problem is those # of nested loops are optimized for 3-spot permutations. How can I could I dynamically set ...

Adding the sum of numbers using a loop statement

I need serious help dividing the positive numbers and the negative numbers. I am to accumulate the total of the negative values and separately accumulate the total of the positive values. After the loop, you are then to display the sum of the negative values and the sum of the positive values. The data is suppose to look like this: ...

Insert statement with where clause.

I had a table with unique Date_t1 date type field, but in Table description field is not mentioned as unique, now while inserting new row i need to validate if date exist or not, If already exist i should not allow to make changes on that row, neither a new row needs to be created, Any idea how to resolve this problem in efficient way, ...

LINQ VB.NET variable not found when looping through grouped query

I'm trying to do the following LINQ grouping, which works in the debugger (the results are populated in the GroupedOrders object. But VS 2008 gives me the following error at design time... Name 'x' is not declared Dim GroupedOrders = (From m In thisConsultant.orders _ Group m By Key = m.commCode Int...

Initializing an array in Java using the 'advanced' for each loop

Is it possible to initialise an array in Java using the 'advanced' for loop? e.g. Integer[ ] numbers = new Integer[20]; int counter = 0; for ( Integer i : numbers ) { i = counter++; } for ( Integer i : numbers ) { System.out.println(i); } This prints all nulls, why is that? ...

Why do I get garbage output when printing an int[]?

My program is suppose to count the occurrence of each character in a file ignoring upper and lower case. The method I wrote is: public int[] getCharTimes(File textFile) throws FileNotFoundException { Scanner inFile = new Scanner(textFile); int[] lower = new int[26]; char current; int other = 0; while(inFile.hasNext()){ ...

How to build shared library (.so file) for chm reader in Android?

Hi. In my application, I want to use chm library. Can anyone tell me How to build shared library (.so file) for chm reader in Android? And which toolchain is used. what is the steps for building it? Thanx in advance. ...

What languages have a while-else type control structure, and how does it work?

A long time ago, I thought I saw a proposal to add an else clause to for or while loops in C or C++... or something like that. I don't remember how it was supposed to work -- did the else clause run if the loop exited normally but not via a break statement? Anyway, this is tough to search for, so I thought maybe I could get some CW ans...