loops

MPMoviePlayer Loop, streaming music

Hi! I have two questions about an application that I'm trying to write. First, is it possible to loop video using the MPMoviePlayerController (without calling play again in the moviePlayBackDidFinish method)? When I do it that way it flashes my apps menu screen before playing again. Second, is it possible to stream music (either from ...

Access outside variable in loop from Javascript closure

See: for (var i in this.items) { var item = this.items[i]; $("#showcasenav").append("<li id=\"showcasebutton_"+item.id+"\"><img src=\"/images/showcase/icon-"+item.id+".png\" /></li>"); $("#showcasebutton_"+item.id).click(function() { alert(item.id); self.switchto(item.id); }); } The problem is that the ...

Iteration over list slices

Good day function-wizards, I want an algorithm to iterate over list slices. Slices size is set outside the function and can differ. In my mind it is something like: for list_of_x_items in fatherList: foo(list_of_x_items) Is there a way to properly define list_of_x_items or some other way of doing this? Thank you greatly. PS: u...

Basic javascript loop/validation question

So im trying to perform a basic validation to check if a field is empty. I want to do it in a loop.. <input type="text" size="25" name="q170_Name" class="text" value="" id="q170" maxlength="100" maxsize="100" /> function validateMe() { var dropdowns = ["q170","q172","q173","q174","q175","q176","q177"]; var totalz = (dropdowns.length);...

A Callback to $.each()'s Callback?

Update: The code below does indeed work as expected, and accomplishes the code I wanted. My confusion was in understanding what I had in my markup when writing the code below - after giving my markup a second look, I realized my code worked perfectly. I've provided my answer below for all who are interested in the more thorough explana...

Store References to Variable in NSMutableArray

Hi Everyone: I am looking for a way to store references to variables inside a NSMutableArray. As variables are going to be created dynamically based upon what the user has chosen, I want to be able to simply sort through this array and get references to these created variables. In case it matters, I am creating a iPhone project. Howe...

Stop a loop inside a method in C#

Is there any way to stop a running loop inside another method or insert a break statement dynamically in C#? Thanks Edit : I want to be able to dynamically intercept the method and insert a break to stop the loop when an event gets triggered in another function.I have several instances of the class and I want to stop the loop in each i...

help with loops in vb

how do i display the following: Q1)1 Q2)1AAAA 00 12BBB 111 123CC 0000 1234D 11111 ...

SQL, How to Concatenate results?

I currently have a SQL query that returns a number of fields. I need one f the fields to be effectively a sub query sub that. The Problem in detail: If I have a table X with two columns, ModuleID and say ModuleValue, how can I write a SQL query to take the results and Concatenate it into one field: EG Results returned from (SE...

JavaScript - Are loops really faster in reverse...?

I've heard this quite a few times. Are JavaScript loops really faster when counting backward? If so, why? I've seen a few test suite examples showing that reversed loops are quicker, but I cant find any explanation as to why! I'm assuming it's because the loop no longer has to evaluate a property each time it checks to see if it's finis...

Why is my for loop stopping after one iteration?

Racking my brains on this one. I have the code below: the first stages of a JavaScript game. All the objects are well-defined and I'm using jQuery for DOM interaction. The puzzle is created with the following JS code: var mypuzzle = new puzzle("{solution:'5+6+89',equations:[['5+3=8',23,23],['5+1=6',150,23],['5+3=6',230,23]]}"); Howev...

Toggling a blog post loop excerpts with jQuery

I'd like to reveal only post titles on my blog posts loop, and when the title is clicked -- the excerpt will appear below. So far I got this: $("#postTitle").click(function () { $("#postExcerpt").toggle(); Which works one the first result only. This, however: $("#postTitle").click(function () { $("#postExcerpt").next().toggle(); ...

Speed comparison of 2 loop styles

I'm reading about STL algorithms and the book pointed out that algorithms like find use a while loop rather than a for loop because it is minimal, efficient, and uses one less variable. I decided to do some testing and the results didn't really match up. The forfind consistently performed better than the whilefind. At first I simply tes...

Using loops to get at each item in a ListView?

What is a nice and effective way of getting at each item in a ListView of more than one column using loops? After doing a fair bit of digging around I couldn't really find anything so I when I did find something I wanted to share it on here see if people have better ways of doing it. Also sort of like preempting a question that is bound...

PHP Retrieve minimum and maximum values in a 2D associative array

I have an array in this format: Array ( [0] => Array ( [id] => 117 [name] => Networking [count] => 16 ) [1] => Array ( [id] => 188 [name] => FTP [count] => 23 ) [2] => Array ( [id] => 189 ...

Ruby Loop Failing in Thread

I have a thread in Ruby. It runs a loop. When that loop reaches a sleep(n) it halts and never wakes up. If I run the loop with out sleep(n) it runs as a infinite loop. Whats going on in the code to stop the thread from running as expected? How do i fix it? class NewObject def initialize @a_local_var = 'somaText' end ...

Multiple PHP WHILE loops using the same query

$query1 = "SELECT * FROM idevaff_affiliates"; $affiliateID = mysql_query($query1) or die(mysql_error()); This is my query above - I would like to use it for two WHILE loops The first one is in the header section - setting up jquery while($row = mysql_fetch_assoc($affiliateID)){ } The second is used in a while loop in the body ...

How make a game loop on the iPhone without using NSTimer

Hi. In order to cleanly port my game to the iPhone, I'm trying to make a game loop that doesn't use NSTimer. I noticed in some sample code that, if using NSTimer, you'd set it up at the beginning with something like self.animationTimer = [NSTimer scheduledTimerWithTimeInterval:animationInterval target:self selector:@selector(drawVi...

How to break outer cycle in Ruby?

Hello. In Perl, there is an ability to break an outer cycle like this: AAA: for my $stuff (@otherstuff) { for my $foo (@bar) { last AAA if (somethingbad()); } } (syntax may be wrong), which uses a loop label to break the outer loop from inside the inner loop. Is there anything similar in Ruby? ...

How do I perform an additional action only on the first iteration of a loop?

I know how to do this... I'll give example code below. But I can't shake the feeling that there's a clever way to accomplish what I want to do without using a variable like $isfirstloop. $isfirstloop = true; foreach($arrayname as $value) { if ($isfirstloop) { dosomethingspecial(); $isfirstloop = false; } dosomething(); } Is th...