Search Results

Search found 8557 results on 343 pages for 'infinite loop'.

Page 85/343 | < Previous Page | 81 82 83 84 85 86 87 88 89 90 91 92  | Next Page >

  • Displaying Nested Array Content with Time Delay in Flex

    - by MooCow
    I have a JSON array that look like this: (array here) I'm trying to use Flex to display each Project and its Milestone elements similar to a nested for-loop for 15 seconds per Milestone element before advancing to the next Project. I was shown a technique that works well for something without another array buried into it. var key:int = 0; var timer:timer = new timer (10000, project.length); timer.addEventListener (TimerEvent.TIMER, function showStuff(event:EVENT):void { trace project[key].projectName; key++; }); timer.start(); But that only replicate a single FOR-LOOP and not a nested FOR-LOOP. Any suggestions?

    Read the article

  • How to run a program in python?

    - by Luka Mihaldinec
    this is my code. I'm trying to make a script which would run an .exe file from my computer. And this one isn't working :/ I think I'm using the wrong command.. I tried all the other commands like import os, os.startfile, but they won't work too. I think my code is just wrong :P loop=0 while loop==0: answer=raw_input("coded by: Narralol\n\n" "Pick a task:\n" "1) Start Minecraft.exe\n" "2) Start Minecraft_Server.jar\n" "3) Backup your server\n" "4) Copy the backup to your desktop\n" "5) Exit\n") if answer==1: execfile('D:\Games\Minecraft\Minecraft.exe') elif answer==2: execfile('D:\Games\Minecraft\Minecraft_server.jar') elif answer==5: loop=1

    Read the article

  • How to create two dimensional array in jquery or js

    - by learner
    I need to create dynamic global two dimensional array in jquery or javascript My function is like this <script> var index = 0; var globalArray = new Array(); function createArray(){ var loop = globalArray[index].length; var name = $.("#uname").val(); if(loop == 0){ globalArray[index][0] = uname; }else{ globalArray[index][loop++] = uname; } } </script> <div><input type="text" id="uname"> <input type='button' value='save' onclick='createArray();'> </div> On click of that button I am getting this error "globalArray[index] is undefined" How can I create one global array using jquery or javascript like this. I dont want any hidden field and all. Please help me. Thanks

    Read the article

  • Looping differences in Ruby using Range vs. Times

    - by jbjuly
    I'm trying to solve a Project Euler problem using Ruby, I used 4 different looping methods, the for-loop, times, range and upto method, however the for-loop and times method only produces the expected answer, while the range and upto method does not. I'm assuming that they are somewhat the same, but I found out it's not. Can someone please explain the differences between these methods? Here's the looping structure I used # for-loop method for n in 0..1 puts n end 0 1 => 0..1 # times method 2.times do |n| puts n end 0 1 => 2 # range method (0..1).each do |n| puts n end 0 1 => 0..1 # upto method 0.upto(1) do |n| puts n end 0 1 => 0

    Read the article

  • Interrupting `while loop` with keyboard in Cython

    - by linello
    I want to be able to interrupt a long function with cython, using the usual CTRL+C interrupt command. My C++ long function is repeatedly called inside a while loop from Cython code, but I want to be able, during the loop, to send an "interrupt" and block the while loop. The interrupt also should wait the longFunction() to finish, so that no data are lost or kept in unknown status. This is one of my first implementation, which obviously doesn't work: computed=0; print "Computing long function..." while ( computed==0 ): try: computed = self.thisptr.aLongFunction() except (KeyboardInterrupt, SystemExit): computed=1 print '\n! Received keyboard interrupt.\n' break; (p.s. self.thisptr is the pointer to the current class which implements aLongFunction() )

    Read the article

  • multiple move operations and data processes in work thread

    - by younevertell
    main thread-- start workthread--StartStage(get list of positions for data process) -- move to one position -- data sampling*strong text*-- data collection--data analysis------data sampling*strong text* basically, work thread does the data sampling*strong text*-- data collection--data analysis------data sampling*strong text* loop for one positioin until press stop or target is obtained. my questions: After work thread finishs the loop for one positioin, it would end itself. now how to make the work thread moves to the next position to do the data process loop after work thread finish one position work, would not end itself until data process for all the positions are done? Thanks in advance!

    Read the article

  • Question about Modal Dialog in Gtk application

    - by michael
    Hi, In Gtk application, there is 1 main loop which listens for events (e.g. mouse click, keyboard, etc). And when a modal dialog popup, the main loop is blocked until user clicks 'OK' in the dialog, right? (i.e. nothing will happen when user clicks on the main window). Is that correct? My question is how can firefox did its modal dialog so that it can: 1. when 1 have 2 Firefox windows 2. one of them has a modal dialog 3. other one is still interactive If both window shares the same gtk main loop, how is that possible? Please help me understanding this. Thank you.

    Read the article

  • What's an easy way of storing an array of numbers in Javascript that I can add/remove from?

    - by SLC
    In C# I would create a List then I could add and remove numbers very easily. Does identical functionality exist in Javascript, or do I have to write my own methods to search and remove items using a loop? var NumberList = []; NumberList.Add(17); NumberList.Add(25); NumberList.Remove(17); etc. I know I can use .push to add a number, so I guess it's really how to remove an individual number without using a loop that I'm looking for. edit: of course, if there's no other way then I'll use a loop!:)

    Read the article

  • Either .each do or .all isn't working how I think it should

    - by user1299656
    So whenever someone rates a shop, I want the Shop model to calculate its new average rating and store that in the database (instead of calculating the average every time someone looks at it). So I wrote the segment of code that follows, and it doesn't work. The loop always iterates exactly once, no matter how many shop_ratings in the database exist that have the shop's id as their shop_id. I played around with it a bit and found that every time a new rating is submitted the function is called successfully, but it only runs the loop once and sets the average to what the first rating was. I don't know if the "query" that sets the ratings variable is wrong or if it's the loop that's wrong. class Shop < ActiveRecord::Base has_many :shop_ratings attr_accessible :name, :latitude, :longitude validates_presence_of :name validates_presence_of :latitude validates_presence_of :longitude def distance_to(lat, long) return (self.longitude - long) + (self.latitude - lat) end def find_average total = 0 count = 0 ratings = ShopRating.all(:conditions => {:shop_id => id}) ratings.each do |submission| total = total + submission.rating count = count + 1 end update_attribute :average_rating, total/count end end

    Read the article

  • how to exit recursive math formula and still get an answer

    - by calccrypto
    i wrote this python code, which from wolfram alpha says that its supposed to return the factorial of any positive value (i probably messed up somewhere), integer or not: from math import * def double_factorial(n): if int(n) == n: n = int(n) if [0,1].__contains__(n): return 1 a = (n&1) + 2 b = 1 while a<=n: b*=a a+= 2 return float(b) else: return factorials(n/2) * 2**(n/2) *(pi/2)**(.25 *(-1+cos(n * pi))) def factorials(n): return pi**(.5 * sin(n*pi)**2) * 2**(-n + .25 * (-1 + cos(2*n*pi))) * double_factorial(2*n) the problem is , say i input pi to 6 decimal places. 2*n will not become a float with 0 as its decimals any time soon, so the equation turns out to be pi**(.5 * sin(n*pi)**2) * 2**(-n + .25 * (-1 + cos(2*n*pi))) * double_factorial(loop(loop(loop(...))))) how would i stop the recursion and still get the answer? ive had suggestions to add an index to the definitions or something, but the problem is, if the code stops when it reaches an index, there is still no answer to put back into the previous "nests" or whatever you call them

    Read the article

  • How can i initialize an array without knowing it size?

    - by Sara
    I have a situation where i have to apply a criteria on an input array and reuturn another array as output which will have smaller size based upon the filtering criteria. Now problem is i do not know the size of filtered results, so i can not initialize the array with specific value. And i do not want it to be large size will null values because i am using array.length; later on. One way is to first loop the original input array and set a counter, and then make another loop with that counter length and initialize and fill this array[]. But is there anyway to do the job in just one loop?

    Read the article

  • Is it a good idea to apply some basic macros to simplify code in a large project?

    - by DoctorT
    I've been working on a foundational c++ library for some time now, and there are a variety of ideas I've had that could really simplify the code writing and managing process. One of these is the concept of introducing some macros to help simplify statements that appear very often, but are a bit more complicated than should be necessary. For example, I've come up with this basic macro to simplify the most common type of for loop: #define loop(v,n) for(unsigned long v=0; v<n; ++v) This would enable you to replace those clunky for loops you see so much of: for (int i = 0, i < max_things; i++) With something much easier to write, and even slightly more efficient: loop (i, max_things) Is it a good idea to use conventions like this? Are there any problems you might run into with different types of compilers? Would it just be too confusing for someone unfamiliar with the macro(s)?

    Read the article

  • Asign Id's dynamically to DOM elements with javascript.

    - by jnkrois
    Hello everybody, I just have a quick question about how to generate id's on-the-fly for HTML elements. So far I've tried a few things, I started with a "for" loop, I already know how many elements I have to generate Id's for, in this case I have an "ul" with 6 "li". My "for" loop is as follows: var items = $("ul li").length; for(var i = 0; i <= items; i++){ $("ul li").attr("id", "number" + i); } "number" would be the new id concatenated with "i", so I get a different Id for each "li". As you can probably tell, this does not work, because I end up with the same Id for each "li": in this case I get <li id="number6">... </li> for all the "li" elments in the "ul". I tried a "while" loop and ".each()" with jQuery but I get the exact same thing. Any help would be appreciated.

    Read the article

  • Thread Jobs in Java

    - by Bragaadeesh
    Hi, I want to spawn 200 threads simultaneously in Java. What I'm doing right now is running into a loop and creating 200 threads and starting them. After these 200 gets completed, I want to spawn another 200 set of threads and so on. The gist here is that the first 200 threads I spawned need to be FINISHED before spawning the next set. I tried the code below, but its not working for(int i=0;i<200;i++){ Thread myThread = new Thread(runnableInstance); myThread.start(); } for(int i=0;i<200;i++){ Thread myThread = new Thread(runnableInstance); myThread.start(); } Note: I have intentionally put the for loop Twice, but the desired effect I intend is not happening simply because the second for loop is executed before the first set of threads end their execution. Please advise

    Read the article

  • DTOs Collections mapping Problem

    - by the_knight5000
    I'm working now on a multi-tier project which has layers as following : DAL BLL GUI Layer and Shared DTOs between BLL and GUI layers. I'm facing a problem in mapping the Objects from DAO To DTO, No problem in the simple objects. The problem is in the Objects who have child collections of another objects. ex: Author Category --Categories --Authors the execution goes in an infinite loop of mapping and it get more complex when I want model Self-join tables ex: Safe Safe --TransferSafe(Collection<Safe>) --TransferSafe(Collection<Safe>) the execution goes in an infinite loop of mapping any suggestions about a good solution or a practical mapping pattern?

    Read the article

  • Parse and Break: why break cannot be used for getting out of "any" or "some" rule ?

    - by Rebol Tutorial
    Let say I have to parse a hierarchical set of tags <tag> <subtag1 attr1=value1 attr2=value2> <subtag1 attr1=value1 attr2=value2> <subtag1 attr1=value1 attr2=value2> </tag> Why can't I use break inside some or any to get out of a level hierarchy ? This would allow to do that kind of parsing instead of having a headache to do so ? I'm asking this because I read here http://www.codeconscious.com/rebol/parse-tutorial.html it would create an infinite loop This case produces an infinite loop. Because the BREAK is within a sub-rule of the rule that SOME is processing. The BREAK does not affect success/failure status or the input pointer - it just exits a rule early: rule-to-break: [(print "Break") break] == [(print "Break") break] parse "X" [some [rule-to-break] "X"] Break *Break* ... Break *Break*(escape)

    Read the article

  • Return multiple results using dynamic sql (postgresql 8.2)

    - by precose
    I want to loop through schemas and get a result set that looks like this: Count 5 834 345 34 984 However, I can't get it to return anything using dynamic sql...I've tried everything but 8.2 is being a real pain. Here is my function: CREATE OR REPLACE FUNCTION dwh.adam_test4() RETURNS void LANGUAGE plpgsql AS $function$ DECLARE myschema text; rec RECORD; BEGIN FOR myschema IN select distinct c.table_schema, d.p_id from information_schema.tables t inner join information_schema.columns c on (t.table_schema = t.table_schema and t.table_name = c.table_name) join dwh.sgmt_clients d on c.table_schema = lower(d.userid) where c.table_name = 'fact_members' and c.column_name = 'debit_card' and t.table_schema NOT LIKE 'pg_%' and t.table_schema NOT IN ('information_schema', 'ad_delivery', 'dwh', 'users', 'wand', 'ttd') order by table_schema LOOP EXECUTE 'select count(ucic) from '|| myschema || '.' ||'fact_members where debit_card = ''yes''' into rec; RETURN rec; END LOOP; END $function$

    Read the article

  • Dynamically changing databases in SQL Server 2000

    - by spuppett
    At work we have a number of databases that we need to do the same operations on. I would like to write 1 SP that would loop over operations and set the database at the beginning of the loop (example to follow). I've tried sp_executesql('USE ' + @db_id) but that only sets the DB for the scope of that stored procedure. I don't really want to loop with hard coded database names because we need to do similar things in many different places and it's tough to remember where things need to change if we add another DB. Any thoughts Example: DECLARE zdb_loop CURSOR FAST_FORWARD FOR SELECT distinct db_id from DBS order by db_id OPEN zdb_loop FETCH NEXT FROM zdb_loop INTO @db_id WHILE @@FETCH_STATUS = 0 BEGIN USE @db_id --Do stuff against 3 or 4 different DBs FETCH NEXT FROM zdb_loop INTO @db_id END CLOSE zdb_loop DEALLOCATE zdb_loop

    Read the article

  • Recursively determine average value

    - by theva
    I have to calculate an average value of my simulation. The simulation is ongoing and I want (for each iteration) to print the current average value. How do I do that? I tried the code below (in the loop), but I do not think that the right value is calculated... int average = 0; int newValue; // Continuously updated value. if(average == 0) { average = newValue; } average = (average + newValue)/2; I also taught about store each newValue in an array and for each iteration summarize the whole array and do the calculation. However, I don't think that's a good solution, because the loop is an infinity loop so I can't really determine the size of the array. There is also a possibility that I am thinking too much and that the code above is actually correct, but I don't think so...

    Read the article

  • Writing a script for reading many .csv files with similar filenames

    - by wahalulu
    I have several .csv files with similar filenames except a numeric month (i.e. 03_data.csv, 04_data.csv, 05_data.csv, etc.) that I'd like to read into R. I have two questions: Is there a function in R similar to MATLAB's varname and assignin that will let me create/declare a variable name within a function or loop that will allow me to read the respective .csv file - i.e. 03_data.csv into 03_data data.frame, etc.? I want to write a quick loop to do this because the filenames are similar. As an alternative, is it better to create one dataframe with the first file and then append the rest using a for loop? How would I do that?

    Read the article

  • What is better: to delete pointer or set it with a new value?

    - by user63898
    Hi simple question in c++ , say i have a loop and i have function that returns pointer to item so i have to define inner loop pointer so my question is what to do with the pointer inside the loop , delete it ? or to set it with new value is good for example: for(int i =0;i<count();i++) { ptrTmp* ptr = getItemPtr(); // do somthing with the ptr ... // what to do here ? to delete the poinetr or not? delete ptr; // ?? }

    Read the article

  • in c++ what is bettr to delete poiner or set it with new value?

    - by user63898
    Hi simple question in c++ , say i have a loop and i have function that returns pointer to item so i have to define inner loop pointer so my question is what to do with the pointer inside the loop , delete it ? or to set it with new value is good for example: for(int i =0;i<count();i++) { ptrTmp* ptr = getItemPtr(); // do somthing with the ptr ... // what to do here ? to delete the poinetr or not? delete ptr; // ?? }

    Read the article

  • connecting… for infinity time

    - by Subhransu
    I have website working fine before. But now its not able to connect to the server(I believe that is the problem). But its strange that the message not able to connect to the server is not coming and its keep connecting... for infinite time. Here is the screenshot. Here are some of the useful details about the status of the server. Application starts when server wakes up are: cd /etc/init.d/ Application server running in my server : Traceroute:

    Read the article

  • Heads-Up! VeriSign Code Signing (Microsoft Authenticode) Certificates $99.00

    - by Edward Boyle
    Recently I posted an article about my Code Signing certificate from GoDaddy. I went with GoDaddy because it is an accepted certificate that should bring no problems; I would have preferred a VeriSign certificate but could not justify the extra $400.00 for the brand considering it truly was not required to meet my needs. I have been around since the day where VeriSign was really the only certificate (SSL) you could get unless you went with the then rogue South African company Thawte, since acquired by VeriSign. Today, I feel out of the loop – very out of the loop. I went to check into Windows Logo requirements, this leads me to this page, that then leads me to this page where I click on the “Digital Certificate’s” Link that leads to this page: So just a heads-up, $99.00 Code Signing Certificate from VeriSign!

    Read the article

  • Get the onended event for an AudioBuffer in HTML5/Chrome

    - by Matthew James Davis
    So I am playing audio file in Chrome and I want to detect when playing has ended so I can delete references to it. Here is my code var source = context.createBufferSource(); source.buffer = sound.buffer; source.loop = sound.loop; source.onended = function() { delete playingSounds[soundName]; } source.connect(mainNode); source.start(0, sound.start, sound.length); however, the event handler doesn't fire. Is this not yet supported as described by the W3 specification? Or am I doing something wrong?

    Read the article

< Previous Page | 81 82 83 84 85 86 87 88 89 90 91 92  | Next Page >