loops

Using Cursor in a Loop of a stored procedure

So as to use cursors dynamically using MySQL is it possible to declare a cursor in a loop of a stored procedure? I've tried and got an error: increment: LOOP DECLARE cur1 CURSOR FOR SELECT person_id, publication_id FROM p_publication WHERE person_id = new_count; DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; OPEN cur1; REPEAT ...

XNA Fighting Game Style Animation Looping Problem

I've been working on this for quite some time looking for solutions in various places. I've used Nick Gravelyn's style of storing animations into a text file and am simply incrementing an index to change frames. The trouble I'm having is looping an animation once and only once, but for some reason the way that I know should work isn't wo...

PHP Text area foreach line

Im trying to code a php script that will loop a process for each line in a Textarea post. I was wondering if someone can post an example. ...

[R] how to avoid loops

HI All, I'm new to R. I have two panel data files, with columns "id", "date" and "ret" file A has a lot more data than file B, but i'm primarily working with file B data. Combination of "id" and "date" is unqiue indentifier. Is there an elegent way of looking up for each (id, date) in B, I need to get the past 10 days ret from file...

Make a multidimensional array through loop!

How can i make an array like below through a loop? The text will generated from database! $listofimages = array( array( 'titre' => 'PHP', 'texte' => 'PHP (sigle de PHP: Hypertext Preprocessor), est un langage de scripts (...)', 'image' => './images/php.gif' ), array( 'titre' => ...

Parse string to JSON

Hi, I'm parsing this JSON string with the libs in org.json and I can't understand why I get the output below into the log. ArrayList<String> al = new ArrayList<String>(); JSONObject demo = new JSONObject("{\"00408C88A2E6\":{\"id\":\"00408C88A2E6\",\"name\":\"Lab\"},\"00408C91188B\":{\"id\":\"00408C91188B\",\"name\":\"Lab1\"},\"00408C944...

SQL - detecting loops in parent child relations

I have parent child data in excel which gets loaded into a 3rd party system running MS SQL server. The data represents a directed (hopefully) acyclic graph. 3rd party means I don't have a completely free hand in the schema. The excel data is a concatenation of other files and the possibility exists that in the cross-references between...

use of infinate loop to create auto-update program

Solved: You guys are the best! I took al the content of goyouidiot_Click and made it into a method called displayResult, and then: private void t1_TextChanged(object sender, EventArgs e) { displayResult(); } How didn't i thought of that before? lol, thx here is original messege: No lone ago i built a little...

On Submit - Check at least one checkbox

Hi, I have multiple check boxes. When the Submit button is clicked I want to check if at least one checkbox is selected. Its not working function doSubmit(){ function check_checkboxes() { checked=false; var c = document.getElementsByTagName('input'); for (var i = 1; i < c.length; i++) { if (c[i].type...

How can I increment a counter every N loops in JMeter?

I want to test concurrency, and reliably replicate an issue that JMeter brought to my attention. What I want to do is set a unique identifier (currently the time in milliseconds with a counter appended) and increment the counter between loops but not between threads. The idea being that the number of threads I have set up is the number ...

Same FOR Loop acts differently (WinXP)

I am trying to write a batch script with a section that ouputs your drive mappings to a text file, so i can restore it later once i wipe out the machine. I came up with this for loop to do it, but its acting differently when its a batch script versus running the command itself. This is the actual line of code: FOR /F "tokens=1,2" %i in...

make data struct iterable in python

Hey everyone, So I've done some looking online and throught the documentation, but I'm having troubling finding out how to do this. I am working on creating an adventure game. I have a level class (which contains a bunch of rooms) and a Room class. I would like to be able to do something like the following. l = Level() for room in l: ...

Should variable declarations always be placed outside of a loop?

Is it better to declare a variable used in a loop outside of the loop rather then inside? Sometimes I see examples where a variable is declared inside the loop. Does this effectively cause the program to allocate memory for a new variable each time the loop runs? Or is .NET smart enough to know that it's really the same variable. For ex...

Avoiding Loop with R using Apply (?)

I'm trying to run apply a function to each row of a dataset. The function looks up matching rows in a second dataset and computes a similarity score for the product details passed to it. The function works if I just call it with test numbers but I can't figure out how to run it on all rows of my dataset. I've tried using apply but can't...

Perl, using variable from within While loop outside of the loop?

This seems really simple but it is giving me a hard time figuring it out as I'm new to perl.. I've been looking through a lot of documentation now about loops and I am still stumped by this... I have a sub that contains a where loop and I want to use a variable value from within the loop outside of the loop (after the loop has run), howe...

How to help the compiler eliminate loops and arrays?

Say you are writing a 3d renderer with support for multi-texturing, where the number of texture units is configured through a compile time constant. Opposed to hard coding a single texture unit, your'e code now has to access texture-related parameters through arrays, and handle them through loops. Assuming a modern C++ compiler, are the...

Magento loop through pages

I found enough documenatation about how to loop through all available categories in Magento, only the thing i want is to loop trough available pages in Magento to include them in my global navigation. So im asking you guys, someone knows how to do this? I imagine myself it should look something like this foreach ($this->getPages() as ...

Modifying nth li in a list using jquery

I'm trying something very basic, but I just can't figure out why this won't work. I can get information on the object using [i] but I can't change data this way? // Make all the li's invisible $('div#rotator ul li').css({opacity: 0.0}); // Calculate a random number between 1 and 3 var randnr = Math.floor((1-4)*Math.random()) + 4; ...

PHP Retry Script until Success or Error

I'm trying to create a php script which retries another php script up to 3 times until an error is displayed. I'm thinking perhaps this could be done using a php loop? If the code works successfully the first time, then there is no need for it to retry 3 times, however, if it doesn't work the first time, then it should retry the php scri...

How to make a scala actor 'wait for the signal' but don't loose any messages?

I'm trying to make an actor 'go to sleep' waiting for another actors signal. I want to do something like: def act(){ loop{ //Should I use loop here too?? if(sleepy){ react{ //SLEEPING case "Wake Up"=> sleepy=false; //just to breack the react } }else{ ...