Reading Constants programatically

I have an application with a module that can return a range of error codes. I would like to be able to turn these codes into meaningful text messages, and I use Constants, like this:

Public Const ERR_UI_4402 = “NO WORKSPACE”

Public Const ERR_UI_4403 = “NO DATABASE”

Public Const ERR_UI_4404 = “DB CREATE ERROR”

Public Const ERR_UI_4405 = “NO DOCUMENT”

What I would like to do is to be able to get the translation from code to text programatically, not have to test each code like this:

If code = 4404 then Messagebox ERR_UI_4404

If code = 4405 then Messagebox ERR_UI_4405 etc.

This needs something equivalent to a FieldGetText command, but these are not field values.

Any ideas?

Subject: Not sure if I got you right…

you can create your own error code / message sets and then use them as if they were predefined. Just include a line similar to this one:

On Error Goto ErrHdl

If (error condition) then

Error YOUR_ERROR_CONSTANT, “Your error message”

End if

ErrHdl:

MsgBox "Error " & Cstr(Err) & ": " & Error$

Resume whatever

For a more complete example you may want to have a look at your Domino Designer’s help file; look for “Err statement” (NOT Err function, though) and then open the example. The example has been the same since at least ND 6 so it doesn’t matter which version you’re actually using.

My sincere apologies if I got your question completely wrong…

Subject: solution

I got this suggestion in R6/7 forum, and it works great … use Lists.

Eg.

Public ReturnCodes List As String

ReturnCodes(“4044”) = “No Database”

ReturnCodes(“4045”) = “No Response”

etc.

Then you can simply say Messagbox ReturnCodes(key) where key = equals 4044, or 4045 or whatever.