loops

Macro to Loop through a range of cells, inputting data into other cells (drop-down selections) and return the result of those calculations

I have a calculator built in Excel 2003 in which you select options from a drop-down menu, data is then gathered and calculated returning your total cost to produce that package of items. What I'd like is to cycle through all the combinations of this drop-down and automatically return the total unit cost to another cell. I have already...

"Too much recursion" error when using intanceof over typeof?

I was making a function to convert all dates in an object to strings and when I used the following function I got a error in FF "too much recursion". (It also fails in IE and chrome) function datesToString(obj) { if (obj instanceof Object) { if (obj instanceof Date) { obj = "this part does not ma...

Looping a Const Char

I need to loop a const char, and I've used a simple example of string loop: const char *str; for(int i = 0; i < 10; ++i) { str += " "; } But when I tried to compile, I got this: ubuntu@eeepc:~/Test_C_OS$ gcc -o kernel.o -c kernel.c -Wall -Wextra -nostdlib -nostartfiles -nodefaultlibs kernel.c:26: error: ‘for’ loop initial dec...

PHP Loop do some once the loop as finished

I have this PHP loop, foreach($returnedContent as $k => $v) { $imageName = str_replace($replaceData, "", $v['contentImageName']); echo "<a class='contentLink' href='".base_url()."welcome/getFullContent/$v[contentId]'>"; echo "<img src='/media/uploads/".strtolower($v['categoryTitle'])."/".$imageName."_thumb.png' alt='$v[cont...

(iPhone) Can I do AudioServicesPlaySystemSound Looping with scheduler?

Can I do AudioServicesPlaySystemSound Looping with scheduler? One problem is I cannot get the sound duration. Is there any way to get the duration so I can dynamically create a scheduler that loops the sound? As far as I know AudioService does not have built-in looping and other necessry functions, and that's really a pain. ...

How can I loop a process that ends in an event? (c#.NET)

I have a process that calls an event when its done. void DoProcess() { ... ... // Call finished event OnFinished(); } I want to run this process many times. My first idea was to recall the process each time the 'Finished' event was called. void obj_Finished() { DoProcess(); } Would this mean that the st...

Using lock statement within a loop in C#

Lets take the sample class SomeThread where we are attempting to prevent the DoSomething methods from being called after the Running property is set to false and Dispose is called by the OtherThread class because if they are called after the Dispose method is the world would end as we know it. It feels like there is a chance for somethi...

efficient loop collapse

in certain applications, I have need to collapse nested loops into one while retaining individual index information. for j in N: for i in M: ... A(i,j) ... // Collapse the loops for ij in MN: ... A(i,j) ... so have looked at the obvious ways to recover i,j from ij using division/modulo (expensive operation) and using if stat...

Loop efficiency - C++

Beginners question, on loop efficiency. I've started programming in C++ (my first language) and have been using 'Principles and Practice Using C++' by Bjarne Stroustrup. I've been making my way through the earlier chapters and have just been introduced to the concept of loops. The first exercise regarding loops asks of me the following...

Jquery loop after click

Hi, I'm using Jquery to submit a form. I want to loop through the form after the user clicks on a submit button to get the select option. There are many different select fields. The select options are generated using PHP. A sample of the HTML: <select id="selectHome_1"> <option></option> </select> <select id="selectHome_2"> <optio...

Dynamicly added movieclip from library tween problem

Hi, I'm having trouble with tweening (with TweenMax) movieclips added dynamically in a for loop. The targeting works fine but the tweens are just not happening. :( My second problem is that I need to randomize my array but I dont know how. Anyway here is my code, and thank you for your help. :D import gs.*; import gs.easing.*; stop(...

looping in unit test bad?

I have a unit test that relies on a random dice roll. I roll a 20 sided die and if the value is 20 it counts as a critical hit. What I'm doing right now is rolling the 20 sided die up to 300 times. If any one of those rolls is a 20 then I know I had a critical hit. Here's what the code looks like: public class DiceRoll { public in...

Beginner Question - Exiting while loop, input type double as condition, C++

Hi, I've only just recent began learning C++ and am having a little issue with while loops when the condition for the while loop is an input, of type double, from the user. I understand that if the user doesn't enter a value compatible with the double type then the loop is automatically broken. The issue is my console application exits u...

foreach in class: I cannot return all the ele in arr.

Hello, Well, I keep improving my form generation classes and stuck in returning all the country elements in country_data array. Only first two elements is displaying on dropdown options. Here is dropdown class: //drop down form class class DropDown { function __construct ($form, $field_label, $field_name, $field_desc, $dropdown_da...

Adding a string in front of a string for each item in a list in python

I have a list of websites in a string and I was doing a for loop to add "http" in the front if the first index is not "h" but when I return it, the list did not change. n is my list of websites h is "http" for p in n: if p[0]!="h": p= h+ p else: continue return n when i return the list, it returns my original...

[VB] For loop problem

I'm using Visual Basic 2008EE and I have a problem with this loop: If x = CType("new", Primitive) Then TextWindow.Write("How many new users would you like to add? ") k = TextWindow.ReadNumber() For mt = 1 To k NewUserEntry() Next and i get this error: "type of 'mt' is ambigious because ...

C# better to initialize list then loop over it, or just initialize in loop condition?

I end up with a lot of code like this: List<string> dates = someMethodCall(); foreach (string dateStr in dates) { } I usually declare the object over which I'm iterating and then use it in the foreach condition out of worry that someMethodCall() would happen for each iteration of the loop. Is this the case? I would prefer to do this...

Bash for loop with wildcards and hidden files

Just witting a simple shell script and little confused: Here is my script: % for f in $FILES; do echo "Processing $f file.."; done The Command: ls -la | grep bash produces: % ls -a | grep bash .bash_from_cshrc .bash_history .bash_profile .bashrc When FILES=".bash*" I get the same results (different formatting) as ls -a. ...

Is it possible to loop input into an array without setting how big the array is in C#?

It's probably a really basic question, but I can't find the answer anywhere. I'm trying to loop through the input and put the results into an array using C#. From what I read the array has to have the number of elements set first. Is there a way to just loop through and have the array number of elements dependent on the number of input...

What is the best means to achieve efficient many-to-many scanning with Django models?

I have a many to many relationship in Django similar as this: class Account ( models.Model ): name = models.CharField( max_length = 30 ) user = models.ForeignKey( User, null = True, blank = True ) class Publisher ( models.Model ): publisherID = models.BigIntegerField( ) name = models.CharField( max_length = 30 ) lastRequested...