loops

Javascript getElementById acting odd...

I'm using a for loop to cycle through some elements with a starting value (seats on a plane). Here it is: seatNum - Number of seats to be cycled through startSeat - seat to begin cycling I'm calling the function from a form "onsubmit". The problem comes in the for loop when i try and go get elements with an id naming convention of "s1...

How to play looping sound with OpenAL on iPhone

I'm following a tutorial about playing sound with OpenAL. Now everything works fine except I can't make the sound looping. I believe that I've used AL_LOOPING for the source. Now it can only play once and when it finishes playing, the app will block(doesn't response to my tap on the play button). Any ideas about what's wrong with the cod...

Optimal way to access a value from the last iteration in a loop

What's the best and fastest way to access a value from the previous iteration in a for loop, assuming that the object will be very large (example, a cursor object which has 100,000+ records) Using a simple example: tmp = [ ['xyz', 335], ['zzz', 338], ['yyy', 339], ['yyy', 442], ['abc', 443], ['efg', 444], ['ttt', 44...

Creating loop for sending variable to other components in Flex

Hi! I have some simple function in Flex in which I would like to send one of my variables to all the components used in my app... The problem is that there is lots of components in my app, and I'm not sure how to reference to my component's id... Basically, is there an easier way to do this; private function preloadStuff():void{ //...

SQLite Flow Constructs in SQL?

With MSSQL, I can mix in case, if...then, and while constructs in my SQL code. Is anything similar available for SQLite? I have not seen anything on "mixing procedurally" with SQLite, anywhere. Thanks. ...

Which is optimal ?

Is declaring a variable inside a loop is good or declaring on the fly optimal in Java.Also is there any performance cost involved while declaring inside the loop? eg. Option 1: Outside the Loop List list = new ArrayList(); int value; //populate list for(int i = 0 ; i < list.size(); i++) { value = list.get(i); System.out.println(“...

Avoiding loops in R

Hello, I have decided to learn R. I am trying to get a sense of how to write "R style" functions and to avoid looping. Here is a sample situation: Given a vector a, I would like to compute a vector b whose elements b[i] (the vector index begins at 1) are defined as follows: 1 <= i <= 4: b[i] = NaN 5 <= i <= length(a): b[i] = mean(a[i...

ExtJS loop through form fields that got a specified name

Hello. I'm using ExtJS 3. I have a formPanel with many "cloned" fields and I gave every field the name "price[]". After submit I would like to loop through every field that has the name "price[]" and get their values one at a time to be checked against something in the database. Note: there are other fields in this form so that's why I ...

Matlab loops for a function

Hi, I am trying to make a loop to redo a Matlab function 1000 times. Here's the program d = unifrnd (0,10,[10,1]); c = d.^(-2); a = round(unifrnd(0,1,[1,10]); e = a*c btotal = e+1 SIR = 1/btotal What I want is to iterate this function 1000 times, each time the value of SIR will vary due to the random number generated. For every iterat...

C# *Strange* problem with StopWatch and a foreach loop

I have the this code: var options = GetOptions(From, Value, SelectedValue); var stopWatch = System.Diagnostics.Stopwatch.StartNew(); foreach (Option option in options) { stringBuilder.Append("<option"); stringBuilder.Append(" value=\""); stringBuilder.Append(option.Value); stringBuilder.Append("\""); if (opti...

validating correct answer with loops in python

Sorry for the non descriptive question I had no idea how to word it. I'm trying to write a program (GUI) where I ask the users questions and then in return they answer and see if they are correct however when I enter the correct answer it's still showing as being incorrect. My code looks something like this. prompt for question 1 txt...

a query controlled loop in java

how can i write a query controlled loop that will continue to input int values from the user,adding each to the value sum,and then ask if the user has another value to input,until the user says that there are no more values ...

Find shortest path between two webpages

I need to find the shortest distance between two Wikipedia pages (in "hops") I have a method to extract all the internal wiki links on a page I know the start destination and the end destination but I'm coming up blank on how to extract the hops from the data so far ive been using the link extraction method to populate a dictionary wi...

Cycle problem in c# cant get this to end >.<

right now im trying to make it so ive got 1 character and 3 enemies if my character dies its suppossed to give game over or something but i cant make it to work(if enemies dies it works tho i dont know why) here is what im doing bool Exit = false; bool CharDead = false; Heroe Heroe1 = p.ElementAt(0); ...

Flash CS4 [AS3]: Generating an array using a loop.

Below I have an array that works but it is far too long and I am thinking there is a far easier way to generate the same result using a loop but I just can't get my head around it at the moment. The array is as follows: var CardDeck = new Array(); CardDeck[0] = new C1(); CardDeck[1] = new C2(); CardDeck[2] = new C3(); CardDeck[3] = new ...

problem with while loop / java

im doing a program which has two different questions, ohm and ampere to be exact. i know how to make this work but the problem is that in the end one more question should pop up asking " do u want to make a new calculation?" this question should work like if i press "Y" the program should continue from the beginning and if i press "N" t...

jQuery - $.each loop through variable object

I'm working with a JSON dataset that has multiple high level objects. If I literally declare the object name, I can loop through the JSON with no trouble, but when I use a variable in its place, I get errors. It appears that it's trying to apply the variable name as the literal name of the object. Here's a quick example function(data){ ...

Quickly Determining the Position of Data in an Array

I have a data structure as the image below illustrates. I need to quickly figure out the index of the cells to the right or left of the highlighted cell group. You can see in the code below I am naively looping through ALL cells at every index to determine if there is a cell at the requested index. This works great when I have a few (...

create JS cursor loop

is there any solutions to make loop after mooving cursor on page in JS? ...

VB6 For Loop on error behavior

Hello All, In VB6, I have the following line of code in the Form_Load event: DOSOMETHING() MsgBox "Done" DOSOMETHING() is a buggy function that I expect to always crash. When I run the app, it will do its thing and crash, without showing the MsgBox. But when I write it using loops: Dim X as Integer For X = 0 to 1000 DOSOMETHIN...