loops

Looping Over Result Sets in MySQL (Resolved: Using Cursors)

I am trying to write a stored procedure in MySQL which will perform a somewhat simple select query, and then loop over the results in order to decide whether to perform additional queries, data transformations, or discard the data altogether. Effectively, I want to implement this: $result = mysql_query("SELECT something FROM somewhere ...

looping through an image folder in a wpf application

I currently am loading all images in a folder in my "MyPictures" folder on my machine which works fine... foreach (string filename in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures))) What I really want to be able to do, though, is load all the images in my Images folder within my solution project. C...

wait for ajax response inside a loop

I need to wait for an ajax response inside a for loop. If I could I'd simply make a synchronous call instead of asynchronous, but I don't have that level of control: I'm using somebody else's API which in turn calls eBay's Javascript API. Below are my two functions, actually methods on the same closure/object, with categoryStack and ca...

xsl recursive loop node by index

I have created a recursive template for getting the first n number of items from my XML. It uses an index(counter) just like how I would in a for loop. Now how can I get a node from my XML using the index? I have tried [position()=$index] but it had weird behaviour when trying to get deeper nodes in the XML hierarchy. If I have XML su...

xsl loop to split a fragment tree every n times

This is a sample of my XML, it can possibly have thousands of rows of items in a range of categories. <store> <products type="computer"> <item desc="text" amount="99"></c> <item desc="text" amount="69.95"></c> <item desc="text" amount="4.50"></c> <item desc="text" amount="10"></c> <item desc="text" amount="9.99"><...

Qt4.5: Using event-loop based localsocket before app.exec

I'm facing a practical problem with Qt. I'm using a class that communicates with QLocalSocket to another process (pipes/unix sockets) and I need to do that communication before other events occur, that is before app.exec() starts (or more precisely,as soon as app starts). The class that I'm using needs an eventloop so it does not work i...

End of 2d array

how can i say in java if i get to the end of a row in a 2d array and i have only encountered 0's in that row to set row to the next one (row ++) and set column to 0 (column = 0)? i am having problems where my algorithm i going in to an infinite loop :D thanks ...

LOOP, LOOPE, LOOPNE?

Can anyone please explain me the difference between the assembly instructions LOOP, LOOPE and LOOPNE. Thanks. ...

jQuery: Possible to wait for $.get to finish loading before continuing?

The folowing script does not wait for $.get to finish loading the page before continuing with the loop: $.each(data.songs, function(index, val) { $('#nowartist') .append('song starting'); $.get("http://localhost/play.php", function(data){ alert('done'); }); }); data is a JSON object Any ideas or comments...

Looping Forever

I'm trying to loop an exception, but for some reason its not giving me the option to re write my scanner file: I don't know how to use BufferedReader so that's why I'm using this. Any clues? Here's my standard class with my method package arrayExceptionsWithInput; import java.util.*; public class GetThoseNumbersBaby { int firstI...

Javascript: Write Console.debug() output to browser?

I need to be able to take any JSON data and print the key/value pairs. (something similar to print_r() in PHP) Is this even possible with javascript? ...

setTimeout inside for loop

Hello. I want a string to appear character-for-character with the following code: function initText() { var textScroller = document.getElementById('textScroller'); var text = 'Hello how are you?'; for(c = 0; c < text.length; c++) { setTimeout('textScroller.innerHTML += text[c]', 1000); } } window.onload = init...

Describe the three elements that must be included in order for a loop to successfully perform correctly

I have this homework question about loops in general (if it make sense at all), it goes like this: Describe the three elements that must be included in order for a loop to successfully perform correctly. Any idea what they might be? ...

Change a Recursive function that has a for loop in it into an iterative function?

So I have this function that I'm trying to convert from a recursive algorithm to an iterative algorithm. I'm not even sure if I have the right subproblems but this seems to determined what I need in the correct way, but recursion can't be used you need to use dynamic programming so I need to change it to iterative bottom up or top down ...

To understand: From PHP Array to Python ?

This is Common task In PHP and other programming languages.I moved from PHP developer. I want to make sure with this collections. Anyone have who good in python please help me to understand clearly . This is my collections from PHP code. <?php $php = array(1,2,3,4,5,6,7,8,9,10); for ($i = 0; $i < 10 ; $i ++) echo $php[$i]."<br>"; ?> =...

Are loops with and without parenthesis handled differently in C?

I was stepping through some C/CUDA code in the debugger, something like: for(uint i = threadIdx.x; i < 8379; i+=256) sum += d_PartialHistograms[blockIdx.x + i * HISTOGRAM64_BIN_COUNT]; And I was utterly confused because the debugger was passing by it in one step, although the output was correct. I realised that when I put curly ...

Java: Alternative to iterator.hasNext() if using for-each to loop over a collection

I'm trying to replace an iterator-based loop over a Java list with a for-each statement, but the code uses at some point iterator.hasNext() to check if it reached the last element in the list. Is there something similar for the for-each alternative? for (Object current : objectList) { if (last-element) do-something-special ...

Is there any way to loop through a struct with elements of diferent types in C?

Hi, my struct is some like this typedef struct { type1 thing; type2 thing2; ... typeN thingN; } my_struct how to enumerate struct childrens in a loop such as while, or for? thanks in advance. ...

PHP sleep() inside loop not updating DB

Hello, I have a php file that is fired by a cronjob every minute. When the php file is fired it updates the database, sleeps, etc It is programmed like this: $start = microtime(true); set_time_limit(10); for($i=0;$i<5;$i++) { updateDB(); time_sleep_until($start + $i + 1); } If this piece of code is run i don't see any chan...

Can we enable looping of rows in a UIPickerView as we do it in UIDatePicker?

I am developing an App where i am struck with the looping of rows in a UIPickerView. Can anyone please help me? it would be of great help if anyone would post the solution. I want the rows in a UIPickerView scroll continuosly in a circular manner without having a end point. ...