473,320 Members | 1,580 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Breaking a loop after an event

Hi all
What I am trying to achieve is this:
I have a FOR loop that is searching in a large data array.
The results are being published to the screen as they are found.
I would like to have a STOP button to terminate the search, so that the user would have the option to call off the search.
Is this possible ?

Thanks In Advance ...
Jan 19 '09 #1
6 1224
Dormilich
8,658 Expert Mod 8TB
does the search take that long to finish? I mean, aborting a function is possible, but most function have quite short execution times (compared to the human reaction time)....
Jan 19 '09 #2
It takes between 10 to 20 seconds.
I forgot to mention that the data is coming from Clearcase (a version control system).
It would be very helpfull if I could stop the search if I found what I want in 3 seconds instead of waiting the whole 20.
Jan 19 '09 #3
Dormilich
8,658 Expert Mod 8TB
if you access the data via AJAX you can use the abort() function.
Jan 19 '09 #4
I'm not.
My code is something like this:
Expand|Select|Wrap|Line Numbers
  1. Cmd="%comspec% /c cleartool lsview " > C:\\output.txt 2>&1"; 
  2. Exec=WshShell.Run(Cmd,0, true); 
  3. ts = fso.OpenTextFile("C:\\output.txt", 1);
  4. msg = ts.ReadAll();
  5. array = msg.split("\n");
  6. for (var i=0; i<array.length; i=i+1)
  7. {
  8.      document.write(array[i]);
  9.      HERE GOES ANOTHER FOR LOOP THAT EXTRACT INFO FROM CLEARCASE AND TAKES A LONG TIME
  10. }
  11.  
Jan 19 '09 #5
I found it !

What I did is create a global variable named STOP and set it to false.
In the OnClick function of the STOP_BUTTON I set the value to true.
Now, on every iteration of my FOR loop, it first checks the value of the variable.
Expand|Select|Wrap|Line Numbers
  1. if (stop==true)
  2.      break;
  3.  
Jan 19 '09 #6
acoder
16,027 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. if (stop) {
would also be fine.
Jan 19 '09 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Anand Pillai | last post by:
This is for folks who are familiar with asynchronous event handling in Python using the asyncore module. If you have ever used the asyncore module, you will realize that it's event loop does not...
4
by: Rhamphoryncus | last post by:
First a bit about myself. I've been programming in python several years now, and I've got several more years before that with C. I've got a lot of interest in the more theoretical stuff (language...
0
by: MarionEll | last post by:
XML Conference 2003 program now available…register with discounts now! IDEAlliance has just released the full program for XML 2003 scheduled December 7-12 at the Philadelphia Convention Center....
0
by: melledge | last post by:
Deadline for XTECH 2005 Late-Breaking News and Vendor Presentations - 28 March The deadline for submission of Late-Breaking News and Vendor Presentations for IDEAlliance's XTCH 2005...
21
by: Alo Sarv | last post by:
Hi From what I have understood from various posts in this newsgroup, writing event loops pretty much comes down to this: while (true) { handleEvents(); sleep(1); // or _sleep() or...
5
by: Uday Deo | last post by:
Hi everyone, I am looping through 4 nested loops and I would like to break in the inner most loop on certain condition and get the control on the 2 nd loop instead of 3rd loop. Here is briefly...
13
by: Sunbags | last post by:
Hello, I'm a 2nd year Computer Engineering student and I have a problem with my VB6 code. I've just started learning VB6 for a project in which we have to create a form which displays the...
6
by: noemailplease0001 | last post by:
Any elegant way of breaking out of the outer for loop than below, I seem to have come across something, but it escapes me for i in outerLoop: for j in innerLoop: if condition: break else:...
13
by: Andrew | last post by:
Hi I was wondering if there is anyway with XML RPC to send a string of text from the server to the client with out calling return thus breaking my loop for example def somefunc(): for...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.