Have you ever needed to verify that a file was really there before you opened it in LotusScript? Nothing is more fun than to try and access a database that's not there. So what do you do? How about checking to see if it exists first?
Now I didn't write this function, so I'll not take 100% credit for it. But I did make some changes so that it returns either True or False when you use it.
If your LotusScript says Print "File Names.nsf is present is " & FileExists("names.nsf") you should get:
Files Names.nsf is present is True since you must have this file in order to run your client or server.
Here is the code:
Function FileExists(filenm As String) As Boolean
' Tests if file exists, returns True for yes, False for no
On Error GoTo FErrorHandler 'Bail on an error
'Test file
If (Dir$(filenm)="") Then
'No file exists
FileExists = False
Else
'File exists
FileExists = True
End If
Exit Function
FErrorHandler:
'We had an error, so we assume there was no file found
FileExists = False
Exit Function
End Function
If it's tech related...I'll post it here. Lotus Notes/Domino, AS400 or iSeries, PC's, PDA's, iPods, Android -- Whatever.
Thursday, March 29, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment