Kbase 19758: 4GL/ABL: How to programmatically get the description of an error message based on its number?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  07/03/2011 |
|
Status: Verified
GOAL:
4GL/ABL: How to programmatically get the description of an error message based on its number?
GOAL:
Where are the files containing the OpenEdge error messages located?
FACT(s) (Environment):
This functionality was offered in earlier releases in the GetMessageDescription procedure from the src/prohelp/msgs.i include file. This code no longer ships with the product.
Progress 9.x
All Supported Operating Systems
OpenEdge 10.x
FIX:
The following code demonstrates how to programmatically get the description of an OpenEdge error message based on its number:
FUNCTION getMsgDataFileName RETURNS CHARACTER
( INPUT piMsgNum AS INTEGER ):
DEFINE VARIABLE iFileNum AS INTEGER NO-UNDO.
DEFINE VARIABLE cDataFile AS CHARACTER NO-UNDO.
iFileNum = TRUNCATE((piMsgNum - 1) / 50, 0) + 1.
cDataFile = SEARCH("prohelp/msgdata/msg" + STRING(iFileNum)).
RETURN cDataFile.
END FUNCTION.
FUNCTION getMsgDescription RETURNS CHARACTER
( INPUT piMsgNum AS INTEGER ):
DEFINE VARIABLE cDescription AS CHARACTER NO-UNDO
INITIAL ?.
DEFINE VARIABLE cMsgFile AS CHARACTER NO-UNDO.
DEFINE VARIABLE cMsgNumber AS CHARACTER NO-UNDO
FORMAT "x(6)".
DEFINE VARIABLE cText AS CHARACTER NO-UNDO
FORMAT "x(78)".
DEFINE VARIABLE cLine AS CHARACTER NO-UNDO
EXTENT 9 FORMAT "x(78)".
DEFINE VARIABLE cCategory AS CHARACTER NO-UNDO
FORMAT "xx".
DEFINE VARIABLE cCategoryArray AS CHARACTER NO-UNDO
FORMAT "x(30)" EXTENT 7.
DEFINE VARIABLE cCategoryCodes AS CHARACTER NO-UNDO.
DEFINE VARIABLE cKnowledgeBase AS CHARACTER NO-UNDO
FORMAT "X(78)".
DEFINE VARIABLE cEol AS CHARACTER NO-UNDO.
DEFINE VARIABLE iCount AS INTEGER NO-UNDO.
DEFINE VARIABLE iPosition AS INTEGER NO-UNDO.
DEFINE VARIABLE cCategoryIndex AS INTEGER NO-UNDO.
cCategoryCodes = "C,D,I,M,O,P,S".
cCategoryArray[1] = "Compiler".
cCategoryArray[2] = "Database".
cCategoryArray[3] = "Index".
cCategoryArray[4] = "Miscellaneous".
cCategoryArray[5] = "Operating System".
cCategoryArray[6] = "Program/Execution".
cCategoryArray[7] = "Syntax".
cEol = CHR(10).
cMsgFile = GetMsgDataFileName(piMsgNum).
IF (cMsgFile GT "") EQ TRUE THEN DO: /* Process Message File */
INPUT FROM VALUE(cMsgFile) NO-ECHO.
ASSIGN iPosition = piMsgNum
iPosition = (piMsgNum MODULO 50) WHEN (piMsgNum MODULO 50) > 0.
/* Skip messages until the one that we are interested in */
DO iCount = 1 TO iPosition ON ENDKEY UNDO, LEAVE:
IMPORT cMsgNumber cText cLine cCategory cKnowledgeBase.
cCategoryIndex = LOOKUP(cCategory, cCategoryCodes).
END.
INPUT CLOSE.
IF (cText GT "") NE TRUE THEN RETURN "No message found to match the number".
IF INTEGER(cMsgNumber) EQ piMsgNum AND
. cText NE "Reserved for Seq " THEN DO: /* Process Description */
iCount = 1.
REPEAT:
IF iCount LE 9 THEN DO:
IF iCount EQ 1 THEN
cDescription = cLine[iCount].
ELSE
cDescription = cDescription + cEol + cLine[iCount].
iCount = iCount + 1.
END.
ELSE
LEAVE.
END. /* repeat */
IF cLine[1] EQ "syserr" THEN
cDescription =
"An unexpected system error has occurred. Please do the following:" + cEol +
"1. If the error occurred while running an existing application or" + cEol +
" during database admin functions, the error may be due to a" + cEol +
" hardware/system problem, r-code corruption, or data corruption." + cEol +
" Note what was processing during the time the error occurred." + cEol +
" Check your system error logs and Progress database log file for" + cEol +
" any additional errors." + cEol +
"2. If the error occurred while running a new application or procedure," + cEol +
" try to reproduce and isolate the code that results in the error." + cEol +
"3. Search the on-line Progress knowledgebase for information on the" + cEol +
" error. The kbase can be accessed via the Progress web site at:" + cEol +
" http://www.progress.com or" + cEol +
" http://www.progress.com/services/techsupport/online.html" &nb.sp; + cEol +
"4. If the above does not lead to resolution, please contact your" + cEol +
" dealer (VAR) who sold you PROGRESS, or the Progress Technical" + cEol +
" Support center for your region.".
cDescription = cText + cEol + cEol + cDescription.
/* Category */
IF cCategoryIndex NE 0 THEN
cDescription = cDescription + cEol + cEol +
cCategoryArray[cCategoryIndex].
/* Knowledge Base */
IF (cKnowledgeBase GT "") EQ TRUE THEN
cDescription = cDescription + cEol + cEol + cKnowledgeBase + ".".
END. /* Process Description */
END. /* Process Message File */
RETURN cDescription.
END FUNCTION.
DEFINE VARIABLE msg-num AS INTEGER FORMAT ">>>9" LABEL "Msg Num" NO-UNDO.
DEFINE VARIABLE shortdescription AS CHARACTER FORMAT "x(80)" LABEL "Short Description" VIEW-AS FILL-IN SIZE 65 BY 1 NO-UNDO.
DEFINE VARIABLE description AS CHARACTER LABEL "Description" VIEW-AS EDITOR INNER-CHARS 70 INNER-LINES 12 SCROLLBAR-VERTICAL NO-UNDO.
DEFINE BUTTON b-close LABEL "&Close".
FORM msg-num
HELP "Enter error number and use TAB or RETURN to view the corresponding description"
shortdescription SKIP
description SKIP
b-close AT 65
WITH FRAME xx THREE-D.
ON LEAVE OF msg-num OR RETURN OF msg-num DO:
ASSIGN
msg-num.
description = getMsgDescription (msg-num).
ASSIGN
shortdescription = ENTRY(1,description, CHR(10)).
DISPLAY
msg-num shortdescription description WITH FRAME xx.
APPLY "ENTRY" TO msg-num.
RETURN NO-APPLY.
END.
ENABLE ALL WITH FRAME xx.
WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW OR CHOOSE OF b-close..