WAIT NOWAIT
WAIT NOWAIT
(OP)
There is a function A. When I call twice
arg = x
DO A(arg)
arg = y
DO A(arg)
if error X occurs in A, own error handler intercepts:
Same result, shows 'BB':
How to display all results, THANKS!
arg = x
DO A(arg)
arg = y
DO A(arg)
if error X occurs in A, own error handler intercepts:
wait 'wrong '+arg WINDOW NOWAIT TIMEOUT 5
. Shows the last call (wrong y)Same result, shows 'BB':
WAIT 'WW' WINDOW NOWAIT TIMEOUT 3
WAIT 'BB' WINDOW NOWAIT TIMEOUT 3
How to display all results, THANKS!
RE: WAIT NOWAIT
Well, wait windows don't "stack up", you only ever have one, the nowait tells VFP to continue with code, and if that doesn't produce another wait window the timeout time tells VFP when to remove the wait window. But if there is another wait window, it replaces the one that didn't yet time out.
You don't have a clause that forces a new window to be created, so you would need a replacement that should be based on a non-modal form, which means it works like the nowait part of a wait window. Well, the only missing thing then is a timeout. That's doable with a timer.
And now I go back to the initial question I ask myself, should I really just focus on that aspect alone. It's very questionable to react to an error just with a wait window and continue to execute. Even only letting slip through some specific errors like wrong argument types, simply rejecting to compute and return a function result, you end up with a state at the caller of which you never know what it causes.
In general, continuing in an error state can cause tables to become corrupt, in the end cause fatal C5 errors hard to debug or anything. You can do controlled error handling with TRY CATCH. And error suppression and continuing with the code can work, if whatever would happen in the normal non-error case was optional anyway.
Still, usually you halt on an error. The default system error handler is a messagebox that's stopping everything and does not time out.
So, I don't see a reason to actually help you with your goal of getting multiple wait windows happening. You have a basic recipe of a non-modal form able to act as a wait window, you could use an editbox within it to display one, or if the form already runs, display multiple messages, one in each line, and automatically extend. So you'd hold on to only one extending wait window. I still don't see the use case for error handling. This could work as status messages, log display, or such things, but shouldn't be used for error handling.
Chriss
RE: WAIT NOWAIT
WAIT 'WW' WINDOW NOWAIT TIMEOUT 3
WAIT 'BB' WINDOW NOWAIT TIMEOUT 3
then you will never see "WW". It will be displayed, but only for a tiny fraction of a second, but it will be immediately replaced by the "BB". Adding a TIMEOUT clause makes no difference.
In this case, the obvious solution is not to use WAIT in your error handler. Either use a message box, or write the error details to a file.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro articles, tips and downloads
RE: WAIT NOWAIT
Chriss
RE: WAIT NOWAIT
The situation is this:
I COPY TO X.dbf files(new ) and if they are already open I get error 1102, but since I copied the same files (old, not update X.dbf) without error, the application takes them(old X.dbf)
I want to warn the user that the files are taken old
RE: WAIT NOWAIT
- Not enough disk space
- No permission for target directory
- Invalid file name.
Which of those applies in this case?
It seems that you are saying that you have two copies of the file X.DBF - an "old" and an "updated" copy. Is that right? Can you clarify that.
In general, if you are worried about a new file overwriting an existing file, you would use FILE() to test for presence of the existing file.
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro articles, tips and downloads
RE: WAIT NOWAIT
RE: WAIT NOWAIT
To copy files, there is the COPY FILE command, and that works with any files. If you want to overwrite old files of same name, then SET SAFETY OFF, that way COPY FILE will overwrite. COPY TO still won't, it will always fail if a file name already exists.
The only advantage COPY TO would have is creating a new file and not copying all deleted records out to the new file. It also creates new CDXes, if you include the WITH CDX clause. While that is a bonus of COPY TO, it takes longer to create a DBF from a workarea than to make the simple binary copy of a file.
If you want to stick to using COPY TO, then erase files you want to overwrite, that would also work. Mike gave you the hint to check with FILE, if it exists you can ERASE (filename) and then COPY TO.
If that's your problem I don't know why you even asked about WAIT WINDOW at all. Because you only ever saw a problem with one file? Well, that would also have been better, if you'd do error handling like it's done usually, by logging errors, at least, if not stopping and reporting them by a messagebox. You'd realize this happens to every file already present in the target directory.
Chriss
RE: WAIT NOWAIT
I have set safety off
I don't need to check if the file exists.
I need verification and processing in the PROCESS of copying the file. When opening a source, I get an error 1102 if the source is already open.
I have never worked with TRY CATCH, apparently the time has come, hope this helps.
RE: WAIT NOWAIT
Chriss
RE: WAIT NOWAIT
CODE -->
RE: WAIT NOWAIT
CODE -->
Mike
__________________________________
Mike Lewis (Edinburgh, Scotland)
Visual FoxPro articles, tips and downloads
RE: WAIT NOWAIT