for-loop

PHP: simplify with algorithm?

Hello. Here's a piece of PHP code I think is not very "pretty", I'm sure it's possible to simplify it with for or something. I'm trying to find and algorithm that would work for this, but I can't figure it out, please help me. Here's the code: if(isset($four)) { if(isset($navi[$one][$two][$three][$four])) echo "/content/" . $one . "/...

Why is this PHP loop rendering every row twice?

I'm working on a real frankensite here not of my own design. There's a rudimentary CMS and one of the pages shows customer records from a MySQL DB. For some reason, it has no probs picking up the data from the DB - there's no duplicate records - but it renders each row twice. <?php $limit = 500; $area = 'customers_list'; $prc = 'custom...

Converting 'foreach' to 'for' loop or vice versa with ReSharper possible?

Hi, Is it possible to mark a foreach loop code block and convert it to a for loop with ReSharper? Or with Visual Studio? Thanks! ...

Why is my for loop stopping after 5 iterations? (in function hello())

<script language="javascript"> function hello() { var selectproducto = document.getElementById("producto"); var totalproducto = document.getElementById("producto").length; var selectmanufacturero = document.getElementById("manufacturero"); var chosenoption = selectmanufacturero.options[selectmanufacturero.selectedIndex].ge...

looping through properties in struct - C

Can I use a forloop to get the property names of a "struct" in C? Or would I just have make a separate list? (Just the name I am looking for) ...

Nested for loop in xquery

Hi, I want to compare the elements on a list using XQuery. For this I'm thiking about using two for loops nested. Something like this: for $i in $node[*[name(.)=$dN][data(.)!=""] and *[name(.)=$hN][data(.)!=""]] return { for $j in $node[*[name(.)=$dN][data(.)!=""] and *[name(.)=$hN][data(.)!=""]] and $j != $i ...

Created a numbered list with For Loop

You would think I would get this done in 10 seconds, but I've spent 1/2 hour and am getting nowhere..Here is what I have/want: <table> <% i=0 %> <% for name in @names%> <% i++ %> <tr> <td><%= "#{i}" %></td> <td><%= name.first %>"></td> </tr> </table> Yes, all I want is a numbered list of names, l...

Custom Rule Editor for .Net

I am working with windows workflow in VS 2008. I need a condition builder to set my rules. The Rule Editor provided by microsoft in WF is good , but we need a simple editor which can be customized. Is there any open source Custom Rule Editor is available for .net ? ...

How to reduce for loop speed.

Hi mates, i'm facing a big issue. i need to generate exact 7 number combinations and i written a code for that by using 7 forloops and also it is working fine with very less numbers.Please check the attachment so you will be very clear what i need actually. Please provide PHP result. <?php // I need the combinations for this commented...

Why doesn't this for loop process the full data set?

Background I have a spreadsheet of ticket allocations for an event. On each row of the spreadsheet is a name and the number of tickets allocated. I need to change the spreadsheet so that each name is duplicated once per ticket on separate rows, like this: I have a macro to do this, however it exhibits strange behaviour The Proble...

VB.NET - Duplicate existing form in FOR loop

Hey, I'm building a code editor app in VB.NET (Framework 4.0) and it opens all ".por" files into individual forms consisting of a MenuBar and TextBox (multi-line). Currently I have 20 forms (all duplicates of the first on I designed) and if there are say 4 ".por" files in a directory, the first four will open up while the others hide. I...

Flash, ActionScript 3: get all movieclips that are containing in a movieclip

Lest just say i have a movieClip A which contains movieClips B1,B2,B3,B4,B5 I write code in A to receive all movieclips that a contains and like print there name. i tried this with no succes: for each (a:MovieClip in this) trace(a.name); does anyone know how to get this working. ** note the trace name is actually an example i ...

Server certificate exception on WSIT client for a WCF Servicve

Hi , I am trying to develop a WSIT client for a WCF Web service. I am currently stuck with a issue for more than 4 days and could not find a solution. I am writing a WSIT client for a WCF web service which requires a mutual certificate authentication. i received the .pfx file from the service provider which i imported to the java trustst...

Is this a bug in AS2?

I have 4 buttons on my canvas named item1, item2, item3 and item4. In the first frame i've written this code(as2): stop(); for (n = 0; n <= 10; n++) { this["item" + n].onPress = function () { trace('lol'); }; } When click the one named item1, it doesn't shows lol, which is funny because if i do this: stop(); for (n = 0; n <= 10;...

Regarding the HTML Label's "For" Property

Considering the following 2 lines of code (copied from w3schools.com > "HTML < label > for Attribute"): <label for="male">Male </label> <input type="radio" name="sex" id="male" /> I am having trouble discovering the exact purpose of the above label's "for" property. As you can see it is currently set to "male" (to match the id of ...

Strange things in JavaScript "for"

Hi. I'm using jQuery and I have a strange thing that I don't understand. I have some code: for (i = 1; i <= some_number; i++) { $("#some_button" + i).click(function() { alert(i); }); } "#some_button" as the name says - they are some buttons. When clicked they should pop-up a box with it's number, correct? But they don'...

looping in two directions

hey I'm looking for are clean solution to this problem: i start the loop with i = 0 in the second loop step the i = 1, then i = -1 and then i = 2 ect. how to programm this with a for loop in a clean way? ...

Get loop count inside a Python FOR loop

In a Python for loop that iterates over a list we can write: for item in list: print item and it neatly goes through all the elements in the list. Is there a way to know within the loop how many times I've been looping so far? For instance, I want to take a list and after I've processed ten elements I want to do something with the...

MATLAB parfor is slower than for -- what is wrong?

Hi, the code I'm dealing with has loops like the following: bistar = zeros(numdims,numcases); parfor hh=1:nt bistar = bistar + A(:,:,hh)*data(:,:,hh+1)' ; end for small nt (10). After timing it, it is actually 100 times slower than using the regular loop!!! I know that parfor can do parallel sums, so I'm not sure why t...

C# - for Loop Freezes at strange intervals

I am working on Problem 14 on Project Euler, and my code seems to freeze at random intervals for no apparent reason. static void Main() { int maxNum = 0; int maxLength = 0; for (int x = 2; x < 1000000; ++x) { int num = x; int length = 0; while (num != 1) { if (num % 2 == 0) ...