Search Results

Search found 15634 results on 626 pages for 'foreach loop container'.

Page 10/626 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • SSIS For Each File Loop and File System Task to copy Files

    - by Marlon
    I'm using a files system task inside a for each loop container, just as described here: link text However, when I execute the package I get this error: [File System Task] Error: An error occurred with the following error message: "The process cannot access the file 'C:\Book1.xlsx' because it is being used by another process.". I do not have the file open, and I assume no one else does, as I am able to copy, and open, and overwrite the file. Any suggestions would be appreciated. If you want an example package plz let me know.

    Read the article

  • How to ignore an exception and continue processing a foreach loop?

    - by Barry Dysert
    I have a test program that is supposed to loop over all the files under C:. It dies when it hits the "Documents and Settings" folder. I'd like to ignore the error and keep looping over the remaining files. The problem is that the exception is thrown in the foreach, so putting a try/catch around the foreach will cause the loop to exit. And putting a try/catch after the foreach never fires (because the exception is thrown in the foreach). Is there any way to ignore the exception and continue processing the loop? Here's the code: static void Main(string[] args) { IEnumerable<string> files = Directory.EnumerateFiles(@"C:\", "*.*", SearchOption.AllDirectories); foreach (string file in files) // Exception occurs when evaluating "file" Console.WriteLine(file); }

    Read the article

  • google maps api v3 - loop through overlays - overlayview methods

    - by user317005
    how can i loop through an array within the overlayview class? $(document).ready(function() { var overlay; var myLatlng = new google.maps.LatLng(51.501743,-0.140461); var myOptions = { zoom: 13, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); OverlayTest.prototype = new google.maps.OverlayView(); var items = [ [51.501743,-0.140461], [51.506209,-0.146796], ]; for([loop])//loop through array { var latlng = new google.maps.LatLng(items[i][0], items[i][1]); var bounds = new google.maps.LatLngBounds(latlng); overlay = new OverlayTest(map, bounds); var element_id = 'map_' + i; function OverlayTest(map, bounds) { this.bounds_ = bounds; this.map_ = map; this.div_ = null; this.setMap(map); } OverlayTest.prototype.onAdd = function() { var div = ''; this.div_ = div; var panes = this.getPanes(); panes.mapPane.innerHTML = div; } OverlayTest.prototype.draw = function() { var overlayProjection = this.getProjection(); var sw = overlayProjection.fromLatLngToDivPixel(this.bounds_.getSouthWest()); var ne = overlayProjection.fromLatLngToDivPixel(this.bounds_.getNorthEast()); var div = document.getElementById(element_id); div.style.left = sw.x + 'px'; div.style.top = ne.y + 'px'; } } }); the above code doesn't work, but when i manually assign a lat/lng to the overlayview class it magically works (see below)?! $(document).ready(function() { var overlay; var myLatlng = new google.maps.LatLng(51.501743,-0.140461); var myOptions = { zoom: 13, center: myLatlng, mapTypeId: google.maps.MapTypeId.ROADMAP } var map = new google.maps.Map(document.getElementById('map_canvas'), myOptions); OverlayTest.prototype = new google.maps.OverlayView(); var items = [ [51.501743,-0.140461], [51.506209,-0.146796], ]; var latlng = new google.maps.LatLng(51.506209,-0.146796);//manually assign lat/lng var bounds = new google.maps.LatLngBounds(latlng); overlay = new OverlayTest(map, bounds); function OverlayTest(map, bounds) { this.bounds_ = bounds; this.map_ = map; this.div_ = null; this.setMap(map); } OverlayTest.prototype.onAdd = function() { var div = ''; this.div_ = div; var panes = this.getPanes(); panes.mapPane.innerHTML = div; } OverlayTest.prototype.draw = function() { var overlayProjection = this.getProjection(); var sw = overlayProjection.fromLatLngToDivPixel(this.bounds_.getSouthWest()); var ne = overlayProjection.fromLatLngToDivPixel(this.bounds_.getNorthEast()); var div = document.getElementById('map_1'); div.style.left = sw.x + 'px'; div.style.top = ne.y + 'px'; } });

    Read the article

  • App crashes often in a for-loop

    - by Flocked
    Hello, my app crashes often in this for-loop: for (int a = 0; a <= 20; a++) { int b = arc4random() % [newsStories count]; NSString * foo = [[NSString alloc]initWithString:[[newsStories objectAtIndex: arc4random() % b]objectForKey:@"title"]]; foo = [foo stringByReplacingOccurrencesOfString:@"’" withString:@""]; foo = [[foo componentsSeparatedByCharactersInSet:[[NSCharacterSet letterCharacterSet] invertedSet]] componentsJoinedByString:@" "]; foo = [foo stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; textView.text = [textView.text stringByAppendingString:[NSString stringWithFormat:@"%@ ", foo]]; } The code changes a NSString from a NSDictionary and adds it into a textView. Sometimes it first crashes in the second time using the for-loop. What did I wrong?

    Read the article

  • Loop over DOMDocument

    - by Zoredache
    I am following the suggestion from this question Robust, Mature HTML Parser for PHP, about parsing html that may be malformed with DOMDocument. Is there any easy way to loop over the parsed document? So I would like to loop over html like this. $html='<ul> <li>value1</li> <li>value1</li> <li>value3</li> </ul> <p>hello world</p>'; $doc = new DOMDocument(); $doc->loadHTML($html); ??? foreach (??? as $node) { print $node->nodeName.':'.$node->nodeValue; } And get results somewhat like this. ul: li:value1 li:value2 li:value3 p:hello world

    Read the article

  • Add characters to month loop?

    - by JM4
    I currently have a php loop running exactly how I need it with proper validations (in both php and javascript) with one exception, if the month is less than 2 digits, (i.e. 1,2,3,4), I need for a '0' to appear before: 01 - January 02 - February ... 10 - October My code for the loop is currently: <select name="Month"> <option value="">Month</option> <?php for ($i=1; $i<=12; $i++) { echo "<option value='$i'"; if ($fields["Month"] == $i) echo " selected"; echo ">$i</option>"; } ?> </select> any ideas? Also note, this month date is being stored in session, not interested in printing to screen

    Read the article

  • How to Loop & rename MySQL table in Perl

    - by Nano HE
    Hi, Could you plesae teach me how to Loop & rename MySQL table in Perl. Thanks. my code snippet attached use strict; use warnings; use DBI; my $dbh = DBI->connect( 'DBI:mysql:database=dbdev;host=localhost', 'dbdev', 'dbdevpw', { RaiseError => 1, AutoCommit => 1 }, ); my $sql = RENAME TABLE old_table TO new_table; my $sth = $dbh->prepare($sql); while (<DATA>){ chomp; // How to implement the Rename all the old tables with the while loop. $sth->execute(); }

    Read the article

  • Good input validation loop using cin - C++

    - by Alex
    Hi there, I'm in my second OOP class, and my first class was taught in C#, so I'm new to C++ and currently I am practicing input validation using cin. So here's my question: Is this loop I constructed a pretty good way of validating input? Or is there a more common/accepted way of doing it? Thanks! Code: int taxableIncome; int error; // input validation loop do { error = 0; cout << "Please enter in your taxable income: "; cin >> taxableIncome; if (cin.fail()) { cout << "Please enter a valid integer" << endl; error = 1; cin.clear(); cin.ignore(80, '\n'); } }while(error == 1);

    Read the article

  • C - is it possible to decrement the max value of a for loop from within the for loop?

    - by hatorade
    for example: void decrement(int counter) { counter--; } int counter = 20; for (int i = 0; i < counter; i++) { for (int j = 0; j < counter, j++) { decrement(counter); } } ideally, what i'd like to see is the counter var being decremented every time the for loop is run, so that it runs fewer than 20 iterations. but gdb shows that within decrement() counter is decremented, but that going back to the for loop counter actually stays the same.

    Read the article

  • Did Delphi ever get a for each loop?

    - by Ryan
    Hello, I've read that Delphi was supposed to get a for each loop in Delphi 9. Did this functionality ever make it into the language? My Delphi 2009 IDE doesn't seem to recognize the for each syntax. Here's my code: procedure ProcessDirectory(p_Directory, p_Output : string); var files : TStringList; filePath : string; begin files := GetSubfiles(p_Directory); try for (filePath in files.Strings) do begin // do something end; finally files.Free; end; end;

    Read the article

  • Drupal and Login Toboggan -- infinite redirect loop

    - by Ian Silber
    I'm getting a redirect loop when using Login Toboggan. It doesn't happen all of the time and I think I've narrowed it down to something with the session, specifically the active-tabs[last-active-href] value. Since it's intermittent, I was able to print out a session of a working copy and a non-working copy. Here are both: WORKS -- Array ( [active-tabs] = Array ( [last-active-href] = index ) ) toboggan/denied DOESN'T WORK -- Array ( [active-tabs] = Array ( [last-active-href] = user/register [user] = user/register ) [wantsEvents] = [wantsResources] = [wantsSupport] = ) toboggan/denied I've also noticed that if I comment out the following line the redirection loop stops (although no page loads): $return = menu_execute_active_handler('user/register'); Any ideas? I'm at my wits end.

    Read the article

  • zsh for loop exclusion

    - by ABach
    This is somewhat of a simple question, but for the life of me, I cannot figure out how to exclude something from a zsh for loop. For instance, let's say we have this: for $package in /home/user/settings/* do # do stuff done Let's say that in /home/user/settings/, there is a particular directory ("os") that I want to ignore. Logically, I tried the following variations: for $package in /home/user/settings/^os (works w/ "ls", but not with a foor loop) for $package in /home/user/settings/*^os for $package in /home/user/settings/^os* ...but none of those seem to work. Could someone steer my syntax in the right direction?

    Read the article

  • Stuck in Infinite Loop while PostInvalidating

    - by Nicholas Roge
    I'm trying to test something, however, the loop I'm using keeps getting stuck while running. It's just a basic lock thread while doing something else before continuing kind of loop. I've double checked that I'm locking AND unlocking the variable I'm using, but regardless it's still stuck in the loop. Here are the segments of code I have that cause the problem: ActualGame.java: Thread thread=new Thread("Dialogue Thread"){ @Override public void run(){ Timer fireTimer=new Timer(); int arrowSequence=0; gameHandler.setOnTouchListener( new OnTouchListener(){ @Override public boolean onTouch(View v, MotionEvent me) { //Do something. if(!gameHandler.fireTimer.getActive()){ exitLoop=true; } return false; } } ); while(!exitLoop){ while(fireTimer.getActive()||!gameHandler.drawn); c.drawBitmap(SpriteSheet.createSingleBitmap(getResources(), R.drawable.dialogue_box,240,48),-48,0,null); c.drawBitmap(SpriteSheet.createSingleBitmap(getResources(),R.drawable.dialogue_continuearrow,32,16,8,16,arrowSequence,0),-16,8,null); gameHandler.drawn=false; gameHandler.postInvalidate(); if(arrowSequence+1==4){ arrowSequence=0; exitLoop=true; }else{ arrowSequence++; } fireTimer.startWait(100); } gameHandler.setOnTouchListener(gameHandler.defaultOnTouchListener); } }; thread.run(); And the onDraw method of GameHandler: canvas.scale(scale,scale); canvas.translate(((screenWidth/2)-((terrainWidth*scale)/2))/scale,((screenHeight/2)-((terrainHeight*scale)/2))/scale); canvas.drawColor(Color.BLACK); for(int layer=0;layer(less than)tiles.length;layer++){ if(layer==playerLayer){ canvas.drawBitmap(playerSprite.getCurrentSprite(), playerSprite.getPixelLocationX(), playerSprite.getPixelLocationY(), null); continue; } for(int y=0;y(less than)tiles[layer].length;y++){ for(int x=0;x(less than)tiles[layer][y].length;x++){ if(layer==0&&tiles[layer][y][x]==null){ tiles[layer][y][x]=nullTile; } if(tiles[layer][y][x]!=null){ runningFromTileEvent=false; canvas.drawBitmap(tiles[layer][y][x].associatedSprite.getCurrentSprite(),x*tiles[layer][y][x].associatedSprite.spriteWidth,y*tiles[layer][y][x].associatedSprite.spriteHeight,null); } } } } for(int i=0;i(less than)canvasEvents.size();i++){ if(canvasEvents.elementAt(i).condition(this)){ canvasEvents.elementAt(i).run(canvas,this); } } Log.e("JapaneseTutor","Got here.[1]"); drawn=true; Log.e("JapaneseTutor","Got here.[2]"); If you need to see the Timer class, or the full length of the GameHandler or ActualGame classes, just let me know.

    Read the article

  • Struggling with a loop

    - by Emil
    Hey. I am trying to make an integer match another integer by adding a number to one of them. I have tried several loop types, but none has worked. Take a look at the code: int favoriteLoop = [favoriteThing intValue]; if (favoriteLoop != [[[array objectAtIndex:favoriteLoop] description] intValue]){ NSLog(@"%d", [[[array objectAtIndex:favoriteLoop] description] intValue]); int favTemp = favoriteLoop; for (int x = favTemp; (favoriteLoop == [[[array objectAtIndex:favoriteLoop] description] intValue]); x++) { NSLog(@"Still not there.."); } } Could anyone help me clear up this mess? It just won't work! Could it have something to do with it allready being inside a for-loop?

    Read the article

  • Strange behaviour with fputs and a loop.

    - by Jonathan
    When running the following code I get no output but I cannot work out why. # include <stdio.h> int main() { fputs("hello", stdout); while (1); return 0; } Without the while loop it works perfectly but as soon as I add it in I get no output. Surely it should output before starting the loop? Is it just on my system? Do I have to flush some sort of buffer or something? Thanks in advance.

    Read the article

  • Using a Loop to add objects to a list(python)

    - by Will
    Hey guys so im trying to use a while loop to add objects to a list. Heres bascially what i want to do: (ill paste actually go after) class x: blah blah choice = raw_input(pick what you want to do) while(choice!=0): if(choice==1): Enter in info for the class: append object to list (A) if(choice==2): print out length of list(A) if(choice==0): break ((((other options)))) as im doing this i can get the object to get added to the list, but i am stuck as to how to add multiple objects to the list in the loop. Here is my actual code i have so far... print "Welcome to the Student Management Program" class Student: def init (self, name, age, gender, favclass): self.name = name self.age = age self.gender = gender self.fac = favclass choice = int(raw_input("Make a Choice: " )) while (choice !=0): if (guess==1): print("STUDENT") namer = raw_input("Enter Name: ") ager = raw_input("Enter Age: ") sexer = raw_input("Enter Sex: ") faver = raw_input("Enter Fav: ") elif(guess==2): print "TESTING LINE" elif(guess==3): print(len(a)) guess=int(raw_input("Make a Choice: ")) s = Student(namer, ager, sexer, faver) a =[]; a.append(s) raw_input("Press enter to exit") any help would be greatly appreciated!

    Read the article

  • Technical non-terminating condition in a loop

    - by Snarfblam
    Most of us know that a loop should not have a non-terminating condition. For example, this C# loop has a non-terminating condition: any even value of i. This is an obvious logic error. void CountByTwosStartingAt(byte i) { // If i is even, it never exceeds 254 for(; i < 255; i += 2) { Console.WriteLine(i); } } Sometimes there are edge cases that are extremely unlikeley, but technically constitute non-exiting conditions (stack overflows and out-of-memory errors aside). Suppose you have a function that counts the number of sequential zeros in a stream: int CountZeros(Stream s) { int total = 0; while(s.ReadByte() == 0) total++; return total; } Now, suppose you feed it this thing: class InfiniteEmptyStream:Stream { // ... Other members ... public override int Read(byte[] buffer, int offset, int count) { Array.Clear(buffer, offset, count); // Output zeros return count; // Never returns -1 (end of stream) } } Or more realistically, maybe a stream that returns data from external hardware, which in certain cases might return lots of zeros (such as a game controller sitting on your desk). Either way we have an infinite loop. This particular non-terminating condition stands out, but sometimes they don't. A completely real-world example as in an app I'm writing. An endless stream of zeros will be deserialized into infinite "empty" objects (until the collection class or GC throws an exception because I've exceeded two billion items). But this would be a completely unexpected circumstance (considering my data source). How important is it to have absolutely no non-terminating conditions? How much does this affect "robustness?" Does it matter if they are only "theoretically" non-terminating (is it okay if an exception represents an implicit terminating condition)? Does it matter whether the app is commercial? If it is publicly distributed? Does it matter if the problematic code is in no way accessible through a public interface/API? Edit: One of the primary concerns I have is unforseen logic errors that can create the non-terminating condition. If, as a rule, you ensure there are no non-terminating conditions, you can identify or handle these logic errors more gracefully, but is it worth it? And when? This is a concern orthogonal to trust.

    Read the article

  • Mystery regarding for-loop.

    - by primalpop
    Hi, I am stuck with this mystery regarding for loop. int abc[3], i, j; for(j=0; j<3; j++); printf("%d\n", j); abc[j] = abc[j] + 3; printf("%d \n", j); Output: 3 6 Output should have been 3,3 as I've not changed value of j. Adding 3 to the jth value of abc has resulted in change of value of j by 3. This happens only while exiting from a for loop and then trying to change the value of abc[j]. Maybe I am missing something pretty obvious. Any help would be much appreciated.

    Read the article

  • int and float increment condition in for loop [on hold]

    - by Mazaya Jamil
    I am doing a program that involves integer and float number.Let say I want to calculate atx={1,1/2,2,3,4} and want to use for-loop. But I know the condition of increment for(x=1;x<=4;x++) as x++=x+1. I want to find the iteration at x={1,2,3,4} and at x={1/2}. But I do not have idea how to modify the for-loop statement; either to make the increment of 0.5 or 1. But if I set 0.5, I will get the answers for 5/2 and 7/2 instead.

    Read the article

  • Problems with 'while' loop and 'for' loop when reading through file

    - by David Beckham
    I wasted plenty of hours trying to figure out the problem but no luck. Tried asking the TA at my school, but he was useless. I am a beginner and I know there are a lot of mistakes in it, so it would be great if I can get some detail explanation as well. Anyways, basically what I am trying to do with the following function is: Use while loop to check and see if random_string is in TEXT, if not return NoneType if yes, then use a for loop to read lines from that TEXT and put it in list, l1. then, write an if statement to see if random_string is in l1. if it is, then do some calculations. else read the next line Finally, return the calculations as a whole. TEXT = open('randomfile.txt') def random (TEXT, random_string): while random_string in TEXT: for lines in TEXT: l1=TEXT.readline().rsplit() if random_string in l1: ''' do some calculations ''' else: TEXT.readline() #read next line??? return #calculations return None

    Read the article

  • PHP modifying and combining array

    - by Industrial
    Hi everyone, I have a bit of an array headache going on. The function does what I want, but since I am not yet to well acquainted with PHP:s array/looping functions, so thereby my question is if there's any part of this function that could be improved from a performance-wise perspective? I tried to be as complete as possible in my descriptions in each stage of the functions which shortly described prefixes all keys in an array, fill up eventual empty/non-valid keys with '' and removes the prefixes before returning the array: $var = myFunction ( array('key1', 'key2', 'key3', '111') ); function myFunction ($keys) { $prefix = 'prefix_'; $keyCount = count($keys); // Prefix each key and remove old keys for($i=0;$i<$keyCount; $i++){ $keys[] = $prefix.$keys[$i]; unset($keys[$i]); } // output: array('prefix_key1', 'prefix_key2', 'prefix_key3', '111) // Get all keys from memcached. Only returns valid keys $items = $this->memcache->get($keys); // output: array('prefix_key1' => 'value1', 'prefix_key2' => 'value2', 'prefix_key3'=>'value3) // note: key 111 was not found in memcache. // Fill upp eventual keys that are not valid/empty from memcache $return = $items + array_fill_keys($keys, ''); // output: array('prefix_key1' => 'value1', 'prefix_key2' => 'value2', 'prefix_key3'=>'value3, 'prefix_111' => '') // Remove the prefixes for each result before returning array to application foreach ($return as $k => $v) { $expl = explode($prefix, $k); $return[$expl[1]] = $v; unset($return[$k]); } // output: array('key1' => 'value1', 'key2' => 'value2', 'key3'=>'value3, '111' => '') return $return; } Thanks a lot!

    Read the article

  • Is possible javascript code to extract c:forEach tag value?

    - by EswaraMoorthyNEC
    Hi, In my i have populate some values using c:forEach tag. I want to get those values in my javascript. If I click GetCtag value button, then i want to read (c:forEach)all values in javascript. Is any other-way to retrieve the c:forEach tag value <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <f:view> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript"> function getCTagValue(ctagObject) { alert("CFor Each Tag Object Value: " + ctagObject); // Here i want write code for retrieve the c:forEach tag value } </script> </head> <body> <h:form id="cTagForm" > <c:forEach items="${cTagBean.tagList}" var="ctag"> <c:out value="${ctag.name} : "/> <c:out value="${ctag.age}"/></br> </c:forEach> <a4j:commandButton id="GetCtagId" value="GetCtag" oncomplete="getCTagValue('#{cTagBean.tagList}')"/> </h:form> </body> </html> Help me. Thanks in advance.

    Read the article

  • Is possible : javascript extract value from c:forEach tag ?

    - by EswaraMoorthyNEC
    Hi, i have populate some values using c:forEach tag. I want to get those values in my javascript. If I click GetCtag value button, then i want to read from (c:forEach) values in javascript. Is any other-way to retrieve the c:forEach tag value <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%> <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <f:view> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <script type="text/javascript"> function getCTagValue(ctagObject) { alert("CFor Each Tag Object Value: " + ctagObject); // Here i want write code for retrieve the c:forEach tag value } </script> </head> <body> <h:form id="cTagForm" > <c:forEach items="${cTagBean.tagList}" var="ctag"> <c:out value="${ctag.name} : "/> <c:out value="${ctag.age}"/></br> </c:forEach> <a4j:commandButton id="GetCtagId" value="GetCtag" oncomplete="getCTagValue('#{cTagBean.tagList}')"/> </h:form> </body> </html> Help me. Thanks in advance.

    Read the article

  • Loop through Array with conditional output based on key/value pair

    - by Daniel C
    I have an array with the following columns: Task Status I would like to print out a table that shows a list of the Tasks, but not the Status column. Instead, for Tasks where the Status = 0, I want to add a tag <del> to make the completed task be crossed out. Here's my current code: foreach ($row as $key => $val){ if ($key != 'Status') print "<td>$val</td>"; else if ($val == '0') print "<td><del>$val</del></td>"; } This seems to be correct, but when I print it out, it prints all the tasks with the <del> tag. So basically the "else" clause is being run every time. Here is the var_dump($row): array 'Task' => string 'Task A' (length=6) 'Status' => string '3' (length=1) array 'Task' => string 'Task B' (length=6) 'Status' => string '0' (length=1)

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >