loops

Line of code causes crash in instruments but not in Xcode

BOOL continueLoop; CGPoint thePoint; while(continueLoop != NO) { continueLoop = NO; thePoint = [self generateRandomLocation]; NSMutableArray *blocks = [self getBlocksForX:thePoint.x]; for(BlueBlock *block in blocks) { if(block.getBlockLocationY == thePoint.y) { continueLoop = YES; } } [blocks release]; } This cause...

VIM: Automatically adding menu-items for scripts from a particular directory

I have a number of scripts (Ruby as it happens) I run from VIM, by setting up the startup file to contain (for instance): amenu Ruby.script1 :%!ruby C:\ruby_scripts\script1.rb<cr><cr> amenu Ruby.script2 :%!ruby C:\ruby_scripts\script2.rb<cr><cr> ... What I would like to do, is to have VIM automatically check the C:\ruby_scripts direct...

real time loop counter ouput wpf

What can I do if I want to have a text-box representing in real time the value of a loop counter in wpf? appending working solution: public partial class Window1 : Window { public Window1() { InitializeComponent(); } private delegate void UpdateTextBox(DependencyProperty dp, Object value); ... private void MyMe...

Looping through files in a folder

Hi, I'm fairly new when it comes to programming, and have started out learning python. What I want to do is to recolour sprites for a game, and I am given the original colours, followed by what they are to be turned into. Each sprite has between 20 and 60 angles, so looping through each one in the folder for each colour is probably the ...

show data with delay from jquery each loop

Hello, My question is the following: What is the best way for looping some json array too show some data with like a one second delay. The one below does not work, because it only shows one message once instead of 4 jQuery.each(data.user, function(index, itemData) { timerid = setTimeout(function(){showMessage(itemData);}, 100...

How to display two table columns per row in php loop

Hi, I would like to display data, two columns per row during my foreach. I would like my result to look like the following: <table> <tr><td>VALUE1</td><td>VALUE2</td></tr> <tr><td>VALUE3</td><td>VALUE4</td></tr> <tr><td>VALUE5</td><td>VALUE6</td></tr> </table> Any help would be greatly appreciated. Thanks ...

Php explode then get the name row from a MySql Table

I know this has been talked about here before. However, my situation is a bit different and I'm so close. I would like to explode an array of category id's from a news data table then get the category name from the category table. Right now I am able to get the id's out and explode them just fine inside the while loop for the news da...

Java: Infinite loop using Scanner in.hasNextInt()

Hi everyone, I am using the following code: while (invalidInput) { // ask the user to specify a number to update the times by System.out.print("Specify an integer between 0 and 5: "); if (in.hasNextInt()) { // get the update value updateValue = in.nextInt(); // check to see if it was within range if (updateV...

Deleting a loop in singly linked list

A loop may occur in singly linked list (SLL). To delete the loop in the list, first we need to detect the loop in the SLL and then delete the loop. Can any one tell how to delete the loop in a SLL with pseudo code? Can we do it using 3 pointers? Is there any alternate to accomplish the task? ...

PHP $_FILES file loop upload

I want to insert files into mysql from php function. The files that need to be uploaded are already present on the server, so I don't want to use the upload form. I want to loop through the directory and get the files info into $_FILES. Please let me know how I will get the $file into $_FILES and then call upload. $dir_handle = @opend...

PHP: display entries from Database in groups of five?

Hi, Is it possible and if so, how can I do it, to select all entries in a table in my database and then display five results at the time in one group. Meaning: A example is that I've 15 records total in my database, then I want to present my data like this: <div class="1-5">Record[1], Record[2], Record[3], Record[4], Record[5]</div> ...

Full In-Browser Window Looping Video

I would like to achieve this effect. Suggestions on how to achieve? ...

How would I do this in php?

I'm implementing a memcache to cache mysql query results. It loops thru the mysql results using while($rowP3= mysql_fetch_array($result3)) { or it loops thru the memcached results (if they are saved in memcache, and not expired) via foreach($cch_active_users_final as $rowP3) { This is probably something thats really obvious... b...

Does a boolean condition in a for loop that is always false get optimized away?

I have the following situation bool user_set_flag; getFlagFromUser(&user_set_flag); while(1){ if(user_set_flag){ //do some computation and output } //do other computation } The variable user_set_flag is only set once and only once in the code, at the very start, its essentially the user selecting what he want...

python: how can i avoid " list index out of range" in this simple while loop

my L1 array contains numbers like 0.029999999999999999 which i want to print off as 0.03 my code works, but gives an error at the end because the last count is out of range. i understand why it breaks, but dont know how to fix it. thanks count = 1 while L1: print "%.2f" %L1[count] count = count + 1 ...

Is it possible to have a while loop in c++ that makes the check in the middle of the loop instead of the beginning or end?

I want to have a while loop do something like the following, but is this possible in c++? If so, how does the syntax go? do { //some code while( expression to be evaluated ); // some more code } I would want the loop to be exited as soon as the while statement decides the expression is no longer true( i.e. if expression i...

Fatal error: Call to a member function prepare() on a non-object

Hi, We have a Document Management application. I have 5000 image files loaded in mysql DB. Need to delete them when the folder is deleted at the client. Using the following code, public function delete($dbh){ $sql = "DELETE FROM fileTable WHERE FID=:fid; DELETE FROM file_blobTable WHERE FID=:fid"; $stmt = $dbh -> p...

Infinite Looping Trigger

I have an after update/insert trigger on table x. In this trigger I need to check if a certain column has been updated which is simple enough doing a deleted/inserted table comparison. However, if a certain column has been changed to a certain value I need to update the inserted row in table x. Doing so obviously creates a loop. The ...

Am I incorrectly using atoi?

I was having some trouble with my parsing function so I put some cout statements to tell me the value of certain variables during runtime, and I believe that atoi is incorrectly converting characters. heres a short snippet of my code thats acting strangely: c = data_file.get(); if (data_index == 50) cout << "50 digit 0 = '" << c <<...

for each loop help

Hi guys i am looping through a list of strings, in psudocode this is how for (each node in my list) if the node.getBooleanVariable == true add one to my counter else take one away from my counter if my counter = another counter print node.getStringVariable() //THIS IS WHERE I AM STUCK here i want ...