for-loop

For loop with a non-integer increment in VB.NET

Can a VB.NET For loop be constructed that mimics this C# code? TimeSpan oneDay = TimeSpan.FromDays(1.0); for (DateTime d = startDate; d < endDate; d += oneDay) { // some code } Obviously you could do it without a For loop (i.e., with a While); I'm just curious if there's a certain syntax to construct a VB.NET For loop with a non-i...

PHP: Check if 0?

Hi, I am using a class which returns me the value of a particular row and cell of an excel spreadsheet. To build up an array of one column I am counting the rows and then looping through that number with a for() loop and then using the $array[] = $value to set the incrementing array object's value. This works great if none of the value...

Stupid newbie c++ two-dimensional array problem.

I've no idea if this is too newbie or generic for stackoverlflow. Apologies if that's the case, I don't intend to waste time. I've just started working through C++ Primer Plus and I've hit a little stump. This is probably super laughable but: const int MONTHS = 12; const int YEARS = 3; int sales[YEARS][MONTHS] = {0}; const string mont...

For vs. while in C programming ?

There are 3 loops in C: for, while, do-while. What's the difference between them? For example, it seems nearly all while statement can be replaced by for statement, right? Then, what's the advantage using while? ...

loop prematurely quitting

This loop works fine but prematurely quits at times. I set a piece of code in it so that I can view the random number. It only closes prematurely when the random number is equal to the highest numbered question the user inputs (Example...a user wants 10 questions, if the random number is 10 the program quits.) I have no idea why since ...

How do I Continue a batch file only if a process IS running

I have successfully managed to hold a batch file until a process ends. But how do I hold a batch file until a process starts? I am working using the following code: @echo off set process_1="calc.exe" set process_2="mmc.exe" set ignore_result=INFO: set no_ignore=mmc.exe :1 for /f "usebackq" %%M in (`tasklist /nh /fi "imagename eq %pro...

pythonic way to do something N times

Hey! Every day I love python more and more. Today, I was writing some code like: for i in xrange(N): do_something() I had to do something N times. But each time didn't depend on the value of i (index variable). I realized that I was creating a variable I never used (i), and I thought "There surely is a more pythonic way of doing...

Python iteration

I'm trying to do a simple script in Python that will print hex values and increment value like this: char = 0 char2 = 0 def doublehex(): global char,char2 for x in range(255): char = char + 1 a = str(chr(char)).encode("hex") for p in range(255): char2 = char2 + 1 b = str(chr(char...

How can I define variables in a for loop in javascript?

I'm trying to define variables within a loop. I'll drop the code here and then try and explain some more: for (var k=0; k<nodes.length; k++){ this[node+k] = new google.maps.Marker({ position: new google.maps.LatLng(array1[k], array2[k]), map: map, title: node[k], icon: "some image file" }); } I ...

How to have 2 counters in for loop C++

Possible Duplicate: How to put 2 increment statements in c++ for loop? How do I declare 2 counters in a for loop in c++ ...

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...

Clean solution to this ruby iterator trickiness?

k = [1,2,3,4,5] for n in k puts n if n == 2 k.delete(n) end end puts k.join(",") # Result: # 1 # 2 # 4 # 5 # [1,3,4,5] # Desired: # 1 # 2 # 3 # 4 # 5 # [1,3,4,5] This same effect happens with the other array iterator, k.each: k = [1,2,3,4,5] k.each do |n| puts n if n == 2 k.delete(n) end end puts k.join(",") ha...

Incremental variable naming convention like i, but for an inside For statement?

Hi experts. This is the example: for(int i = 0; i < 10;i++) { for(int ? = 0;? < 10 ; ?++) { } } I usually use an "o" for the second loop, but is there any standard out there? ideas? Thanks. ...

Loop through array in JavaScript

In Java you can use a for() loop to go through objects in an array like so: String[] myStringArray = {"Hello","World"}; for(String s : myStringArray) { //Do something } can you do the same in JavaScript? ...

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...

Loop over array and set all vars to false or true in javascript

Hi All, I need to loop over my array and set all the vars to false or true. I have tried numerous options, none of which are working and it's clearly my lack of javascript syntax knowledge..Please take a look at this: var closeAllCells = [IncomeOpen = "false", RehabOpen = "false", AttendantCareOp...

Javscript Loop / Array / Variable question

Hi. I'm trying to get this to work and I hope this isn't too vague. -Chris var example = new Array(); var test1 = "one"; var test2 = "two"; var test3 = "three"; for (v = 1; v <= 3; v++) { alert(example[test + v]) } I want the alert to say: one two three ...

Flash AS3 button eventlistener array bug

Hi there, this is my first time posting a question here. I have an array of 12 buttons on a timeline that when first visiting that part of the timeline, get a CLICK eventlistener added to them using a for loop. All of them work perfectly at that point. When you click one it plays a frame label inside the specific movieClip and reveals...

AS3 URLRequest in for Loop problem

Hi guys, I read some data from a xml file, everything works great besides urls. I can't figure what's the problem with the "navigateURL" function or with the eventListener... on which square I click it opens the last url from the xml file for(var i:Number = 0; i <= gamesInput.game.length() -1; i++) { var square:square_mc = new squa...

Asynchronous Request make for-Loop waiting for didFinishLoading

Hey guys, I have a asynchronous url request within a for loop. This loop is called 20 times, each time one parameter of the webaddress is changed. Everytime the didFinishLoading method is called I want to hand over the data of this specific webadress. The problem now is that when I run the for loop, the didFinishLoading method is not c...