Option Public Option Explicit '** Error code masks Const ERR_MASK = &H3fff Const PKG_MASK = &H3f00 Const ERRNUM_MASK = &H00ff Declare Function OSLoadString Lib "nnotes.dll" (Byval hModule As Long, Byval stringCode As Integer, _ Byval retBuffer As String, Byval bufferLength As Integer) As Integer Sub Initialize '** this agent will export all the possible Notes API error codes and descriptions '** to a comma-delimited text file '** Julian Robichaux -- http://www.nsftools.com Dim fileName As String Dim fileNum As Integer Dim i As Integer Dim errString As String fileName = "C:\APIErrors.csv" fileNum = Freefile() Reset Open fileName For Output As fileNum Print #fileNum, "Notes API Errors" Print #fileNum, "(some of these are informational messages used by Notes and not true errors)" Print #fileNum, "" Write #fileNum, "Error Number", "Hex Number", "Error Message" For i = 0 To &H3FFF errString = GetAPIError(i) If (Len(errString) > 0) Then Write #fileNum, i, Hex$(i), errString End If Next Close fileNum Print "Finished Exporting Errors" End Sub Function GetAPIError (errorCode As Integer) As String '** this function translates Notes API error codes into their '** corresponding error strings Dim errorString As String*256 Dim returnErrorString As String Dim resultStringLength As Long Dim errorCodeTranslated As Integer '** mask off the top 2 bits of the errorCode that was returned; this is '** what the ERR macro in the API does errorCodeTranslated = (errorCode And ERR_MASK) '** get the error code translation using the OSLoadString API function resultStringLength = OSLoadString(0, errorCodeTranslated, errorString, Len(errorString) - 1) '** strip off the null-termination on the string before you return it If (Instr(errorString, Chr(0)) > 0) Then returnErrorString = Left$(errorString, Instr(errorString, Chr(0)) - 1) Else returnErrorString = errorString End If GetAPIError = returnErrorString End Function
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.