In case,
define variable due_date as date.
define variable mynumber as integer.
assign due_date = mynumber.
the condition above will cause error in progress editor
" ** Incompatible data types in expression or assignment."
but I need to handle this statement by myself to tell the which data is incompatible with which data.
the message should show
"cannot assign mynumber(integer) to due_date(date)".
I don't know how to capture compiler error message and use my own error message.
Removed since the suggestion was invalid since I misunderstood the question.
Message was edited by:
Matthew Baker
The closest you can get is to do a
COMPILE ... NO-ERROR.
followed by a traversal of the ERROR-STATUS:GET-MESSAGE() list.
Even then, there's no way to figure out what caused the error and replacing it with the kind of error detail you're describing. What makes it even more fun is that the compiler doesn't always report the line # where the error happened, but the "first" line number of the compiled statement. For instance:
IF logical-value THEN
assign due-date = mynumber.
would report the "IF" statement as the line # where the error happened, not the ASSIGN statement.
thank you for suggestion.
From your description, you are trying to catch this at compile time. I am wondering why since the code can't compile until you fix the type mismatch and the error message you are already getting is telling you that the type mismatch exists. To really give a message with more detail ... and we have all wanted that from time to time ... would require meddling with the innards of the compiler, to which we have no access.
From your description, you are trying to catch this at compile time. I am wondering why since the code can't compile until you fix the type mismatch and the error message you are already getting is telling you that the type mismatch exists. To really give a message with more detail ... and we have all wanted that from time to time ... would require meddling with the innards of the compiler, to which we have no access.