loops

Simple array loop question Objective-C

How can you make this work? numbers = [[NSMutableArray alloc] initWithObjects: ({int x = 0; while (x <= 60 ) { return x; x++; } })]; Thanks :) ...

I'm trying to make a loop with jQuery...

All I need it to do is run the function animateAds over and over. Can anyone help? This is my code: function animateAds(n) { $('#ad_1').fadeIn('slow', function (){ $('#ad_1').delay(100).fadeOut('fast', function (){ $('#ad_2').fadeIn('slow'); }); }); }; $(document).ready(function() { for (n = 0;...

Question about loops and continue

So is this actually naming the loop to nextLoop? So when it says continue nextLoop, does it go back to the top right away? var total = 0; nextLoop: for ( var i = 0; i < 7; ++i ) { for ( var j = 0; j < 6 ; ++j ) { if ( i < 5 ) continue nextLoop; total++; ...

Is it better to use integers as loop counter variables?

I remember reading somewhere that it is better to use integers as loop counter variables rather than char or short. If yes, why? Does it provide any optimization benefits? ...

Get a Try statement to loop around until correct value obtained

Hello, I am trying to get a user to enter a number between 1 and 4. I have code to check if the number is correct but I want the code to loop around several times until the numbers is correct. Does anyone know how to do this? The code is below: def Release(): try: print 'Please select one of the following?\nCompletion = 0...

JavaScript: Refactoring looping regex

How might this be improved, as it pertains to the loop and the regex replace? var properties = { ... }; var template = element.innerHTML; for (var name in properties) { template = template.replace (new RegExp('\\${' + name + '}', 'gm'), properties[name]); } element.innerHTML = template; Is there a way I could get all the...

Null check in an enhanced for loop

What is the best way to guard against null in a for loop in Java? This seems ugly : if (someList != null) { for (Object object : someList) { // do whatever } } Or if (someList == null) { return; // Or throw ex } for (Object object : someList) { // do whatever } There might not be any other way. Should they...

Help with looping Pictures

Hi guys my code for collision detection is as follows i need it to loop through 55 pictures on the main form //aliens are named alien1, alien2 ect //image2 is the collison object ( the bullet) CODE IS TURBO DELPHI procedure TForm1.TimeralienshotTimer(Sender: TObject) var ax2 : integer; bx2 : integer; ay2 : integer; by2 : integ...

Javascript - what does this line do?

What does the following javascript do? var groups = countrylist.split(','); for( var i = -1, group; group = groupsCounty[++i]; ){ ... } ...

Help me automate a procedure in excel

I have an excel sheet with values in columns A, B and C like this: A B C 1 8.22 1.99902 32.48974 2 8.22 3.04698 33.92426 3 8.22 2.26374 33.1547 4 8.22 2.78227 33.2593 6 8.22 2.46798 33.34269 6 8.22 2.57802 33.67131 7 8.22 2.46798 32.7427 8 8.22 2.57802 33.07131 There is also a ce...

Loop in code block on click argument.

Basically what i am trying to do is display a list of categories. And if the admin is logged in i want to show some buttons next to each category. For example a button to delete it. The problem is that i dont know how to pass a parameter to the function that does the action. Like i specify that on button click the function 'DeleteCat' ...

How to make this jQuery Vertical News Scroller NOT repeat/loop

I found this scroller that I would like to use, however, I want it to stop after showing the last item. http://www.cre.lt/tadas/vticker.php Is it possible? Tracy ...

looping loops in ruby (noob)

n = 0 m = 40 o = 0 while n < m n = n + 1 end while n = m o = o + 1 n = 0 end With that code, what would be the best way to make it so once it went through the second loop it would go back through the first??? Any help for this beginner is welcomed. :) ...

Why is 'for(var item in list)' with arrays considered bad practice in JavaScript?

Given a simple zero based, numerically indexed array: var list = ['Foo', 'Bar', 'Baz']; Many times, I have noticed that when someone suggests looping through variables in an array like this: for(var item in list) { ... } ...there's almost certainly someone suggesting that that's bad practice and suggests an alternative approach: v...

Android: Looking for an easy way to play notification sounds in a loop manually

Hi there! I am fiddling around with a dialog that pops up and displays an alarm information. (I know, it has been documented that in Android it's "better" style to use notifications instead, but just like the alarm clock I want it to display a dialog on top of whatever you do to really get the users immediate attention - as the user expe...

PHP get last iteration foreach loop value

Ok I have a foreach loop and wanted to know if I could get the last iteration data value for the current iteration? Code: foreach($array as $key=>$data) { echo "Key: ".$key." Data: ".$data."<br />"; } Results: Key: 0 Data: 23244 Key: 0 Data: Program ID: 39-1-1499-1 Results I would like: Key: 23244 Data: Program ID: 39-1-1499-1...

Nested loops always confuse me

So I have a loop to be nested inside another loop based on two queries. I have the first loop working fine- $sql_categories = mysql_query("SELECT * FROM $categories_table"); $results = mysql_query("SELECT * FROM $events_table"); while ($num_rows = mysql_fetch_assoc($sql_categories)) { extract($num_rows); echo "<h2>...

A random number generator statement in a loop is giving me the same number every time. Javascript

So I am writing this loop, and I have a random number generator in it. How come it only picks one random number for all the iterations of the loop instead of a new random number? here's my code: for ( i = 0; i < 25; i++ ) { var randNum = 0; var randNum = Math.floor(Math.random() * 5); } this is in the chrome browser. Is there someth...

How to generate year in Smarty?

How can i generate a select list with the given year till this year? i did this {assign var=thisyear value=$smarty.now|date_format:"%Y"} {if !$firstyear} {assign var=firstyear value="2003"} {/if} {if !$loop}{assign var=loop value=$thisyear}{/if} <select name='{$id|default:year}' id={$id|default:year} style='width:70px;'> {section na...

How to add a seperator between menu items in PHP but not on the end

I'm trying to put an image as a separator between menu items but not on the outside and I'm not sure how to do this.. So it would end up being something like this: HOME | ABOUT | CONTACT unfortunately my code puts one after every entry including the last one. mysql_select_db($database_db_connection, $db_connection); $query_rsMenu = "S...