Let's say I have
some_value = 23
I use the integer and the .times to loop.
Inside the iteration, is there an easy way, without keeping a counter, to see what iteration the loop is currently in?
...
I am trying to assign salespeople (rsSalespeople) to customers (rsCustomers) in a round-robin fashion in the following manner:
Navigate to first Customer, assign the first SalesPerson to the Customer.
Move to Next Customer. If rsSalesPersons is not at EOF, move to Next SalesPerson; if rsSalesPersons is at EOF, MoveFirst to loop back to...
How do you make a function read form a txt file and store random lines in a variable? It will be run over and over in a foreach loop. The language is PHP.
Im a new coder so I don't know things like this off the top of my head.
...
I'm trying to use jquery to loop through a block of forms that contain numeric data and add it all up to be displayed in a form with id grand. I have the ability to dynamically add new forms, so the number of forms I'm looping through will change. Here's my jquery code I wrote that isn't working for whatever reason:
$('#table').delegate...
i want to create an animation where the ball will move in one of the 4 sectors of a circle randomly.this will happen 5 times.so,i create a while loop(i<5) and call the random function.i then create an if loop and attach some x and y values according to the random fn value.i then create an timeline object inside the while loop and in the ...
With my limited experience/knowledge I am using the following structure to generate HTML tables on the fly from MySQL queries:
$c = 0;
$t = count($results);
$table = '<table>';
while ($c < $t) {
$table .= "<tr><td>$results[0]</td><td>$results[1]</td> (etc etc) </tr>";
++$c;
}
$table .= '</table>';
this works, obviously. But f...
Hi.
I've got a database table with at least three rows in it. From php, I have successfully connected to my db and extracted all table information with 'SELECT * from mytable' .
Now I want to loop through first each row, and then each cell, printing out the contents of each cell.
I know this might be a simple task for a more experienc...
Hello All
I am working on an AJAX script but am having difficulties. First, here is the script:
var xmlHttp;
function GetXmlHttpObject(){
var objXMLHttp=null
if (window.XMLHttpRequest){
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject){
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
...
I have an object of type Hash that I want to loop over via hash.each do |key, value|. I would like to get the number of times I've been through the loop starting at 1.
Is there a method similar to each that provides this (while still providing the hash key/value data), or do I need to create another counter variable to increment within...
I'm trying to pull the field names in the header of some JSON output. The following is a sample of the JSON header info:
{"HEADER":{"company":{"label":"Company Name"},"streetaddress":{"label":"Street Address"},"ceo":{"label":"CEO Name","fields":{"firstname":{"label":"First Name"},"lastname":{"label":"Last Name"}}}
I'm able to loop th...
{% for d in mydata %}
{{ d.title }}
{% endfor %}
However, I would like the first one to be bolded. How can I use the loop to say...if the d is the first one, then bold it?
...
I have this string that shall come in from another file. The string has maximum length of 102 digits. I need to compare the string with numbers in a pair and delete those from that string.
e.g - 6125223659587412563265... till 102
numbers that compare with this string-
first set - 61
new string = 25223659587412563265
second set - 36...
I have an array, which holds values like this:
$items_pool = Array (
[0] => Array ( [id] => 1 [quantity] => 1 )
[1] => Array ( [id] => 2 [quantity] => 1 )
[2] => Array ( [id] => 72 [quantity] => 6 )
[3] => Array ( [id] => 4 [quantity] => 1 )
[4] => Array ( [id] => 5 [quantity] => 1 )
[5] => Array ( [id] => 7 [quantity] => 1 )
[6] ...
I have been running some small tests in PHP on loops. I do not know if my method is good.
I have found that a inverse loop is faster than a normal loop.
I have also found that a while-loop is faster than a for-loop.
Setup
<?php
$counter = 10000000;
$w=0;$x=0;$y=0;$z=0;
$wstart=0;$xstart=0;$ystart=0;$zstart=0;
$wend=0;$xend=0;$y...
In scala, you often use an iterator to do a for loop in an increasing order like:
for(i <- 1 to 10){ code }
How would you do it so it goes from 10 to 1? I guess 10 to 1 gives an empty iterator (like usual range mathematics)?
I made a scala script which solves it by calling reverse on the iterator, but it's not nice in my opinion, is ...
I can draw many things using this :
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"dummy2.png" ofType:nil];
UIImage *img = [UIImage imageWithContentsOfFile:imagePath];
image = CGImageRetain(img.CGImage);
CGRect imageRect;
double x = 0;
double y = 0;
for (int k=0; k<someValue; k++) {
x += k;
y += k;
...
var grossBrackets = new Array( '300', '400', '500', '600', '700', '800', '900', '1000' );
function bracketSort( itemToSort ) {
for( index = 0 ; index < grossBrackets.length ; index++ ) {
if ( itemToSort < grossBrackets[index] ) {
bracketData[index]++;
} else if ( itemToSort > grossBracke...
I've got the following in one of my Oracle procedures, I'm using it to generate XML
-- v_client_addons is set to '' to avoid null error
OPEN C_CLIENT_ADDONS;
LOOP
FETCH C_CLIENT_ADDONS INTO CLIENT_ADDONS;
EXIT WHEN C_CLIENT_ADDONS%NOTFOUND;
BEGIN
v_client_addons := v_client_addons || CLIENT_ADDONS.XML_DATA;
E...
Background:
I have two 2d arrays. Each index within each 2d array represents a tile which is drawn on a square canvas suitable for 8 x 8 tiles.
The first 2d array represents the ground tiles and is looped and drawn on the canvas using the following code:
//Draw the map from the land 2d array
map = new Canvas(mainF...
Basically, I want to do something like this (in Python, or similar imperative languages):
for i in xrange(1, 5):
try:
do_something_that_might_raise_exceptions(i)
except:
continue # continue the loop at i = i + 1
How do I do this in Ruby? I know there are the redo and retry keywords, but they seem to re-execu...