Need to trap “File Not Found” error when testing path string

35 pts.
Lotus Domino
Hello I am processing loose files and have a text-file list of paths. Using the GetFileAttr(path$) it works just fine as I can separate out the directories from the files themselves. Problem - when the code encounters a bad file name I can't trap the error, Notes pops up a "File Not Found" error and the code terminates. Is there a better way to test string values to see if they are valid files? I have tried putting in an err_handler but Notes simply produces the "File Not Found" error pop-up. To test the problem you can code a button with the follwing script: Sub Click msg$ = Inputbox$("enter a file name", "filename","c:boc.txt") attr%= Getfileattr(msg$) Messagebox Str(attr%) End Sub Thanks for your help - Mike

Answer Wiki

Thanks. We'll let you know when a new response is added.

I don’t understand why you can’t trap the error. Using your sample code, I just created a button, but added a basic error handler and it worked just fine. What did your error handling code look like?

Discuss This Question: 3  Replies

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • CharlesJC
    mHanson, You could try using the Dir$ function to test the validity of paths and file names. For example, If Dir$(msg$) "" then 'process the file Esle 'handle your incorrect information Messagebox "File """ & msg$ & """ not found." End If This should be placed before your call to GetFileAttr. Also, why didn't trapping Err = 5 (File Not Found) work? Charles
    0 pointsBadges:
  • Brooklynegg
    Stilleto: Agreed. mHanson should be able to put in a generic error handler and this line to find out the error number, Messagebox "Error" & Str(Err) & ": " & Error$ ...then code a specific action to occur when that number is encountered. In my example below, error 75 is returned if I try to access a folder that does not exist and my code creates the new folder (I actually can't remember exactly how it does it, but I know it works). Example: On Error Goto Errhandle ....code here Exit Sub Errhandle: ' Use the Err function to return the error number and ' the Error$ function to return the error message. If Err = 75 Then Resume Next Else Messagebox "Error" & Str(Err) & ": " & Error$ Exit Sub End If End Sub
    3,845 pointsBadges:
  • Stiletto
    CharlesJC, I think you may have miskeyed. I think the error number is 53. AKA ErrFileNotFound if using lserr.lss
    5,500 pointsBadges:

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.


Share this item with your network: