loops

How to loop and array's index by day in xcode

I know the question sounds a little funny. I am trying to move down the list of array in my iPhone project. I have an array of 100 items: [0][1]...[99] I would like to select index[0] today, index[1] tomorrow... index[99] 100 days from now. And then on day 101, back to index [0]. Maybe I need to convert NSDate and get todays date in...

Writing a number in an array that has the same number of counts like the number

Hi, I am working on a paging function. This is what I have: $total_pages = 3; // 3 is only an example foreach ($total_pages as $single_page): echo 'Page'.$single_site->number.'|'; endforeach; How can I write the number of pages in array that I can use in my foreach function? The number of pages is dynamical. I want to be able, to s...

ConcurrentDictionary: super slow?!

I have a file I'm trying to parse, and this is how I'm doing it: var definitions = new Dictionary<int, string>(); foreach (var line in new RirStatFile("delegated-lacnic-latest.txt")) { for (var i = 0; i < line.Range; i ++) { definitions[line.StartIpAddress + i] = line.Iso3166CountryCode; }; }; new RirStatFile(...)...

Excel export to Word (VBA): problem with loop

Hi everyone, I'm having difficulties with the following: I want to export data from an Excel Sheet to a Word document. The code for that works, but the problem is that specific blocks of code need to be repeated. And that's were it goes wrong. This is an extract of the code: Voortgang: If Controle1 = True Then ...

Looping code when hovering with set delay in JavaScript with jQuery

Hi there, I'm looking to start and stop a loop with a set delay with a jQuery hover event. I've been trying to do it with "mouseover" and "mouseout" with no luck. Example (odd psudocode): Mouseover Loop Change text colour Wait 100ms Mouseout Stop loop I'm sure this is super easy, I just don't quite know how to...

Improving loop efficiency/extensibility

I have an array of pixels which make up a 2D grid and I want to move these pixels right and left over time... constantly however the loop I came up with is fairly inefficient and does not allow for much expansion in terms of changing the motion. Any ideas on how to improve what I already have would be much appreciated. while (true) { ...

Pagination with Mysql and PHP Help

Hey guys. I am trying to create a pagination with just next and previous links instead of 1,2,3..etc. So I have say item 1,2,3,4,5 in the database and each item is on one page. If I am on item 2 page I would like a previous link for item 1 page and a next link for item 3 page...etc So far I got up to retrieving all the items in the d...

Loop problem. Cin C++ getline clear buffer

I am having a problem, but I cannot figure out what I'm doing wrong. I'm not sure if it's a problem with my loop, or the cin buffer is not being cleaned. I am doing a program that transforms a C-style string to uppercase, however if the user enters more than 11 characters, then the function should only display the first 11, and anything ...

How should I replace my naughty JSLint-shy function defs within loops?

I'm getting a few "Don't make functions within a loop." errors from JSLint, anyone got any tidy suggestions on how to fix this stuff up? Perhaps my naughtiness is excusable because of my YAHOO dependencies (yd. below)? I can safely say that the only time I've done the following: for( var i=0; i<FLN.revealers.length;i++ ) { var revE...

Unix Script to Process multiple file names

I'm writing a script that will fold, sort and count text in a file. I need to design the program so that, if it is given multiple filenames on the command line, it processes each one separately, one after the other. I think I could write a loop but I don't know that much about those yet so if possible would like to try other options. Are...

Why wont it loop? (PHP and MySQL)

I wrote this code: <?php mysql_connect("localhost", "root", "root") or die("Could not connect: " . mysql_error()); mysql_select_db("internal"); $result = mysql_query("SELECT Title, Message FROM msg"); ?> <?php while ($row = mysql_fetch_array($result, MYSQL_NUM)){ ?> <div> <h3><a href="#"><?php printf("%s", $row[0...

Inserting into HTML5 database with jQuery loop

Hi, Javascript is not my forte, so excuse me if this is incredibly obvious. I'm working on some code that creates a local database and table, retrieves an RSS feed, parses it, and adds information from each entry to the database. $.ajax({ type: "GET", url: feedurl, dataType: "xml", success: parseXml }); function parse...

Input value undefined inside nested loop - jquery

Hi, I have been trying to solve this for a while. I am trying to get value of a form input which is inside a nested loop. But its coming undefined. Any idea why so? Thanks much for your help in advance. Here is the code for example. I am getting the value of $(#fund-no-"+f).attr('value') without any problem. Its $("#year-" + year_amt +...

How to pause Python while Tkinter window is open?

I'm writing a program that sometimes encounters an error. When it does, it pops up a Tkinter dialog asking the user whether to continue. It's a more complicated version of this: keep_going = False KeepGoingPrompt(keep_going) if not keep_going: return The prompt sets keep_going to True or leaves it False. Problem is, the code seems ...

Loop in Adobe Flex

Hi guys, I'm new to Flex programming.. and I need to do some iteration. How do I perform loops in Flex? And does Flex has "switch case"? Thanks guys ...

Initiating the same loop with either a while or foreach statement

I have code in php such as the following: while($r = mysql_fetch_array($q)) { // Do some stuff } where $q is a query retrieving a set of group members. However, certain groups have there members saved in memcached and that memcached value is stored in an array as $mem_entry. To run through that, I'd normally do the following foreac...

How do I alternate display of 2 elements continuously in jQuery?

Hi I have two image elements: <img src="/image1.gif" id="id1" /><img src="/image2.gif" id="id2" /> I'm trying to create a continuous loop in jQuery whereby image1.gif is shown for 1 second, then disappears and image2.gif is shown for 1 second and so on, alternating for N seconds. I've just about hit a wall with it. Has anyone got ...

Looping through input form problem

I'm having an issue when I loop through form input text fields. I am trying to loop through multiple text fields labeled 'number' and it's only submitting the very last number field instead of all 'number' fields. Can anyone see what I'm doing wrong here?? for ($i = 0; $i < count($_POST['number']); $i++) { $sql='INSERT INTO o...

how do you iterate over a list in django

This is a sample view code def link(reqest): title = ['Home Page', 'Current Time', '10 hours later'] return render_to_response('time.html', title) This is a sample template code {% for item in title %} {{item}} {% if not forloop.last %} | {% endif %} {% endfor %} This is a sample url code (r'^now/$', current_time,...

Multiplying and Dividing by Two

Why are these two snippets of code giving two different results? double sum = 1.0; double xSqFour = x * x / 4; for (int i = 48; i > 1; i-=2) { sum = 1.0 + (xSqFour / ((i/2) * (i/2))) * sum; } return sum; and double sum = 1.0; double xSqFour = x * x / 4; for (int i = 24; i > 1; i--) { ...