Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Can exit loop when called directly but not from menu
Message
From
08/01/2005 14:39:44
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00975330
Message ID:
00975432
Views:
15
Hi again Barbara,

I don't know if this thread is another attempt to find a solution to your 'abort a long process' problem? Anyway, I have thought about your problems, and I have a great idea on how you can get the result you want.

I suggest you make a completely separate small exe, let's call it 'stopprocess.exe' which has only one command button, with caption 'Stop processing' or something like that. This exe will monitor the presence of a file, let's call the file 'working.bus', using a timer which will check for this file frequently. If working.bus exists, the command button is visible, if not, it will 'kill itself' by exiting. The only line of code in the click event of this comamnd button is 'erase working.bus'. After the command button is clicked, the file is not there, and the program will 'kill itself'.

So your programs, in which you want to give the users the chance to abort the time consuming process, will be something like this:
strtofile('x','working.bus') && or strtofile(str(this.top)+chr(13)+chr(10)+str(this.left),'working.bus')
run stopprocess
scan while file('working.bus')
   ... Processing code here
endif
if file('working.bus')
  erase working.bus && Will make stopprocess 'kill itself'
endif
In the load event of stopprocess.exe, you may have code to read the contents of working.bus, which you then will give information about the top and left of the 'Stop processing' commaand button.
**Load
if file('working.bus'
  xx=FILETOSTR('working.bus')
  This.cmdStop.top=val(mline(xx,1))
  This.cmdStop.left=val(mline(xx,2))
endif
In my example you must change "this" in the line "strtofile(str(this.top)+chr(13)+chr(10)+str(this.left),'working.bus')" so that you get the exact top and left you want.

I hope you understand my idea, and that you can use it.

>I've got a really strange problem. I've got a form that runs a long process within a loop. I want the user to be able to hit Escape to exit the loop. I've implemented this in the standard way:
>
>llXit = .F.
>on escape llXit = .T.
>set escape on
>scan while not llXit
>   ... Processing code here
>   DOEVENTS
>endif
>
>This works as expected if I just DO FORM.... from the Command Window. However, if I call it from the menu of my app, it either ignores the Escape key or hangs. The menu option is just a command that says DO FORM... just like I do from the command window. The form has a private datasession.
>
>I'm sure there's some difference in the environment between the two situations that's causing this difference in behavior, but I can't figure out what it is. Anyone have suggestions as to what I can check?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform