while-loops

Is there a such thing as a while each loop in Java?

If there were such a thing I would imagine the syntax to be something along the lines of while(Integer item : group<Integer>; item > 5) { //do something } Just wondering if there was something like this or a way to imitate this? ...

How do you Make A Repeat-Until Loop in C++?

How do you Make A Repeat-Until Loop in C++? As opposed to a standard While or For loop. I need to check the condition at the end of each iteration, rather than at the beginning. ...

Infinite loop in SharePoint Workflow

Hi guys, I'm making a demo workflow that is a while loop with a sequence of a single delay, that delays for 5 seconds. I've made the while loop use a Declarative Rule Condition where I set it to 1 == 1. All fine, but the loop only ever loops once, and then my workflow sais "Error Occurred". Any idea what's going on? For the record, th...

Continue in nested while loops

In this code sample, is there any way to continue on the outer loop from the catch block? while { // outer loop while { // inner loop try { throw; } catch { // how do I continue on the outer loop from here? continue; } } } ...

Assigning value in while loop condition

I found this piece of code on Wikipedia. #include <stdio.h> int main(void) { int c; while (c = getchar(), c != EOF && c != 'x') { switch (c) { case '\n': case '\r': printf ("Newline\n"); break; default: printf ("%c",c); } } return 0; } I'm curious about expression ...

Java for loop vs. while loop. Performance difference?

Assume i have the following code, there are three for loop to do something. Would it run fast if i change the most outer for loop to while loop? thanks~~ int length = 200; int test = 0; int[] input = new int[10]; for(int i = 1; i <= length; i++) { for (int j = 0; j <=length - i; j++) { for (int k = 0; k < length - 1...

Can I damage the system by running time.sleep() with this newbie code in Python?

Hi! Im sure there is a better way to do this, but I am quite the newbie so I did it the only way I could figure it out. The thing is, I have a script that updates a textfile with the newest posts from an RSS feed (I got some help from you guys to figure it out). But I want this script to be automated, so I made this: import time import...

Loop nesting and I'm getting a blank page (php)

Here's what I got- $awards_sql_1 = mysql_query('SELECT * FROM categories WHERE section_id = 1') or die(mysql_error()); $awards_rows_1 = mysql_num_rows($awards_sql_1); $awards_sql_2 = mysql_query('SELECT * FROM categories WHERE section_id = 2') or die(mysql_error()); $awards_sql_3 = mysql_query('SELECT * FROM categories WHERE section...

Stumped in the middle of a PHP loop

Here's what I've got so far- $awards_sql_1 = mysql_query('SELECT * FROM categories WHERE section_id = 1') or die(mysql_error()); $awards_sql_2 = mysql_query('SELECT * FROM categories WHERE section_id = 2') or die(mysql_error()); $awards_sql_3 = mysql_query('SELECT * FROM categories WHERE section_id = 3') or die(mysql_error()); $awards_s...

Even more lost than before - stumped with a PHP loop

Okay, so I followed the advice on this question: http://stackoverflow.com/questions/1214176/stumped-in-the-middle-of-a-php-loop But now, I'm having even more problems than before. Here's what I have so far: $sql = "SELECT section_name, category_name, result_level, url, winner FROM 2009_RKR_bestof INNER JOIN categories ON 2009_RKR_best...

how to loop over looped elements?

I'm creating a tree-structure of categories with parentid's which can be called from children in such a way: ID | Name | ParentID 1 1 0 2 2 1 3 3 2 4 4 1 Resulting in this: 1 = 1 2 = 1 -> 2 3 = 1 -> 2 -> 3 4 = 1 -> 4 which means 3 is a child of 2, which is a child of 1. when trying to get this idea ...

Should "while loops" be preferred to "for loops" for large, necessary loops in R?

Realizing that loops are usually not ideal in R, sometimes they are necessary. When writing large loops, doesn't for (i in 1:large_number) waste memory, since a vector of size large_number must be created? Would this make while loops the best choice for large, necessary loops? ...

What is the maximum number of executions in a while loop in VB.net that it will allow?

What is the maximum number of executions in a while loop in VB.net that it will allow? Meaning, it is checking for a variable to equal some value, but that value never comes? How many times will it execute the code before it quits? Is there some way to set the maximum number of executions without terminating it programmatically? Thanks ...

Help with Python while loop behaviour

I have a script that uses a simple while loop to display a progress bar but it doesn't seem to be working as I expected: count = 1 maxrecords = len(international) p = ProgressBar("Blue") t = time while count < maxrecords: print 'Processing %d of %d' % (count, maxrecords) percent = float(count) / float(maxrecords) * 100 p.ren...

What is the advantage of a do-while(false)?

When looking through some code that was handled by another employee, I see a lot of code written in: do{ ... }while(false); What advantage (if any) does this provide? Here is more of a skeleton that is happening in the code: try{ do{ // Set some variables for(...) { if(...) break; // ...

Help While Loop in C

I'm new to C programming, I come from a Java background. I was wondering why in the following code, in the while loop I have to type my input ten times and then all ten inputs are displayed. I'm trying to type something once and have it displayed right after. Then continue typing my other inputs. #include <stdio.h> #include <stdlib.h> ...

Difference between while (x = false) and while (!x) in Java?

Sorry, I'm new to Java, so this question might be unclear. I have been recently dealing with enclosing a try and catch statement in a while loop, because I wanted to make sure that getting input was enclosed from the rest of the program. I have come across a problem where using an exclamation mark in front of a variable in the while con...

How to implement a do-while loop in tsql

I'm trying to figure how to implement this in TSQL do update stuff set col = 'blah' where that_row = 'the right one' select trash from stuff ... until some_condition The only iterative control flow sentence provided by Transact-SQL is while (condition) sentences that first evaluates the condition and if that condition is true the...

Example of a While Loop that can't be a For Loop

I know a while loop can do anything a for loop can, but can a for loop do anything a while loop can? Please provide an example. ...

How to make my own while Loop just like Wordpress Loop?

Hi all programmer... im new here and new in PHP too.. Just wondering how to make my own flexible loop just like in Wordpress... Note im not talking about wordpress.. I want to implement it on myown PHP application... let's look back in WP, there is a code something like this: while (have_post() : thepost())// .. bla bla... echo the_t...