loops

Question about sizeof. I want to reverse bits in number.

What will be equivalent of this in Java? for (i = (sizeof(num)*8-1); i; i--) num is given number, not array. I want to reverse bits in integer. ...

Java Sound Clip Looping Frame Position

Hi, I have a little problem with a loopting clip: If you have a soundfile e.g. 20000 samples long, the frame position will not reset after looping, so I get values that are "out of bounds" of the original soundfile. As I want to draw a position marker on my waveform, I'm a bit confused how to achive. At this time I just get myClip.getLo...

How do I loop through a Python list by twos?

Possible Duplicate: What is the most pythonic way to iterate over a list in chunks? I want to loop through a Python list and process 2 list items at a time. Something like this in another language: for(int i = 0; i < list.length(); i+=2) { // do something with list[i] and list[i + 1] } What's the best way to accomplish t...

Variable Assignment and loops (Java)

Greetings Stack Overflowers, A while back, I was working on a program that hashed values into a hashtable (I don't remember the specifics, and the specifics themselves are irrelevant to the question at hand). Anyway, I had the following code as part of a "recordInput" method. tempElement = new hashElement(someInt); while(in.hasNex...

Partials vs for loop — best practices

In coding up your view templates you can render a partial and pass an array of objects to be rendered once per object. OR you can use a For blank in @blank loop. How do you decide when to do which? It seems that if you use a partial for every iterable object you will end up having to modify tons of separate files to make changes to poten...

Help me refactor my World Cup Challenge Script

I am setting up a World Cup Challenge between some friends, and decided to practice my Ruby and write a small script to automate the process. The Problem: 32 World Cup qualifiers split into 4 tiers by their Fifa ranking 8 entries Each entry is assigned 1 random team per tier Winner takes all :-) I wrote something that suffices yet...

ASP.net - Does a return statement in function stop the function?

Given the function 'Returns true if no cell is > 1 Function isSolutionValid() As Boolean Dim rLoop As Integer Dim cLoop As Integer For cLoop = 0 To canvasCols - 1 For rLoop = 0 To canvasRows - 1 If canvas(cLoop, rLoop) > 1 Then Return False End If Next Next Retu...

Stop While true loop with a specific or any key pressed in a php script

Hi, I want to stop a while true loop when a specific or any key is pressed. I know I can ctrl-c the script but I am locking tables in my MySql database, and I doesn't want to unlock them in the beginning of the script because i want to be able to run multiple instance of the script. Thank you for any insight ...

C# Dynamically reference objects in loop

I don't know whether this is possible or not. What I want to do is to reference a DataTable (and other objects, but getting it working for one will make the rest easy) and use it as a paramater, but I want to do this in a loop, so that I can perform the function with each DataTable dt1, dt2, dt3 etc. Something like this (although this ob...

Flash AS3: position loaded images from loop based on image height

I'm trying to dynamically stack images that are being pulled in via an xml file. Below is what I'm doing, and it almost works. The problem is that it only seems to fire off the event complete function on the very last one, instead of going for all of them. Is there a way to make it run the even.complete function for each image? function...

for loop in iPhone

nodes = [doc nodesForXPath:@"//user" error: nil]; for (CXMLElement *node in nodes) { [itemPreDict setObject:[[node attributeForName:@"name"] stringValue] forKey:@"name"]; [itemPreDict setObject:[[node attributeForName:@"gender"] stringValue] forKey:@"gender"]; [itemPreDict setOb...

Php random row help...

I've created some code that will return a random row, (well, all the rows in a random order) But i'm assuming its VERY uneffiecent and is gonna be a problem in a big database... Anyone know of a better way? Here is my current code: $count3 = 1; $count4 = 1; //Civilian stuff... $query = ("SELECT * FROM `*Table Name*` ORDER BY `Id` ASC"...

PHP MYSQL Endless Loop

Hi, I have a problem with my php/mysql script. It should only output the while loop once but I am getting unlimited loops and an endless page. $query = mysql_query("SELECT * FROM users WHERE username ='".base64_encode($_SESSION['username'])."' LIMIT 1"); $result = mysql_fetch_array($query); if(empty($result)){ echo "No user......

Rotating do while PHP

Hello all! Well I have unusual question I think. I am making a web site and the products must be shown as a line I will past a link for better understanding. http://partyclub.mdkbg.com/products_carbonated_mix.html Clicking the bottle in the right will change the products to the next. But if you keep clicking will see that when the end...

For...Next Loop Multiplication Table to Start on 0

I have my For...Next loop with a multiplication table working just fine, but I want the top left box to start at 0 and move on from there. Giving me some trouble. dim mult mult = "<table width = ""100%"" border= ""1"" >" For row = 1 to 50 mult = mult & "<tr align = ""center"" >" For col= 1 to 20 mult = mult & "<td>"...

Define 2D array with loops in php

I have an array $rows where each element is a row of 15 tab-delimited values. I want to explode $rows into a 2D array $rowData where each row is an array element and each tab-delimited value is assigned to a different array element. I've tried these two methods without success. I know the first one has a coding error but I do not know ho...

How to loop a video in Flash

So i had a video that was in quicktime format, threw it into flash, encoded it without a problem and here is the result i got: http://www.healthcarepros.net/travel.html I would like the video to "loop" or "autorewind" as soon as it ends but i am having the hardest time trying to figure how to do this. Here is my code, any help would be ...

A more condensed way of doing the following loop?

I have the following for-loop. It uses the values 0-6 form monday-sunday respectively. Is there a more condensed way to do this? As opposed to listing out the if ($i=="day") // $i = 0 is monday... $i = 6 is Sunday for($i=0;$i<7;$i++){ if ($i==0) echo ' <input name="repeat_on_week[]" type="checkbox" value="0" /> Monday'; ...

How can I test potentially "browser-crashing" JavaScript?

I've been having a crack at some of the problems over at http://projecteuler.net/ with JavaScript. I've been using a simple html page and running my code in script tags so I can log my results in the browsers' console. When experimenting with loops I sometimes cause the browser to crash. Is there a better environment for me to do this ...

Newb Question: scanf() in C

So I started learning C today, and as an exercise i was told to write a program that asks the user for numbers until they type a 0, then adds the even ones and the odd ones together. Here is is (don't laugh at my bad style): #include <stdio.h>; int main() { int esum = 0, osum = 0; int n, mod; puts("Please enter some number...