- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am trying to detect when a file on a network drive is accessible. I can detect when there is a problem using GETFILEINFOQQ and GETLASTERRORQQ. I then get the app to wait for a period and then retry. If the resource is available, then GETFILEINFOQQ is successful, but the last error is still reported.
Is there any way to clear the last error once the error has been handled (by waiting in my example)?
Thanks,
David
Is there any way to clear the last error once the error has been handled (by waiting in my example)?
Thanks,
David
Link Copied
7 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - David White
I am trying to detect when a file on a network drive is accessible. I can detect when there is a problem using GETFILEINFOQQ and GETLASTERRORQQ. I then get the app to wait for a period and then retry. If the resource is available, then GETFILEINFOQQ is successful, but the last error is still reported.
Is there any way to clear the last error once the error has been handled (by waiting in my example)?
Thanks,
David
Is there any way to clear the last error once the error has been handled (by waiting in my example)?
Thanks,
David
Why dont you use the handle that GETFILEINFOQQ returns? It has the value FILE$ERROR if the file dont exist...
When debug, in the first run it steps into i=1, then I copy the file, debug further and then I geti=2.
Markus
[cpp]handle = FILE$FIRST result = GETFILEINFOQQ (files, info, handle) if(handle==file$error) then i = 1 else i = 2 end if ! copying file to the right dir handle = FILE$FIRST result = GETFILEINFOQQ (files, info, handle) if(handle==file$error) then i = 1 else i = 2 end if[/cpp]
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - onkelhotte
Why dont you use the handle that GETFILEINFOQQ returns? It has the value FILE$ERROR if the file dont exist...
I wanted more specific information about the cause of the error, so I was using GETLASTERRORQQ. However my logic in checking for FILE$ERROR was incorrect, which meant I was checking the last error even when the last call had not flaggedan error.
Thanks,
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - David White
I wanted more specific information about the cause of the error, so I was using GETLASTERRORQQ. However my logic in checking for FILE$ERROR was incorrect, which meant I was checking the last error even when the last call had not flaggedan error.
Thanks,
David
Youre right, this doesnt solve the GETLASTERRORQQ problem... But finding your file problem ;-)
So, when you use a function or subroutine, that can produce an error that is recognised by GETLASTERRORQQ you cannot say if it is the same error (and the result has the same value) or if there was no error at all and the value doesnt change because of that. Doesnt the doctor have a cure or suggestion?
Markus
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't know of a way to clear the error code, but you might consider the Win32 API GetLastError() to see if it better meets your needs. However, I generally don't ask for the "last error" unless an operation has returned to me with a status saying it failed. Calling GETLASTERRORQQ repeatedly does not seem to me to fit in with its design.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - David White
I am trying to detect when a file on a network drive is accessible. I can detect when there is a problem using GETFILEINFOQQ and GETLASTERRORQQ. I then get the app to wait for a period and then retry. If the resource is available, then GETFILEINFOQQ is successful, but the last error is still reported.
Is there any way to clear the last error once the error has been handled (by waiting in my example)?
Thanks,
David
Is there any way to clear the last error once the error has been handled (by waiting in my example)?
Thanks,
David
Use the Win API. IIRC do something like
errres=GetLastError()
Call SetLastError(errres)
Gerry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - g.f.thomas
Use the Win API. IIRC do something like
errres=GetLastError()
Call SetLastError(errres)
Gerry
I think it will actually need
Call SetLastError(0)
to clear the error.
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Quoting - David White
Quoting - g.f.thomas
Use the Win API. IIRC do something like
errres=GetLastError()
Call SetLastError(errres)
Gerry
I think it will actually need
Call SetLastError(0)
to clear the error.
David
I more or less agree. The last time I used this I did
USE IFWINTY
USE KERNEL32
IF(GETLASTERROR() /= ERROR_SUCCESS) CALL SETLASTERROR(ERROR_SUCCESS)
Gerry
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page