# EsbGetMessage

Description

EsbGetMessage() retrieves the top message from the message stack filled during VB API function execution if ClientError in ESB_INIT_T structure has been set to ESB_TRUE during EsbInit().

Syntax

    EsbGetMessage (hInst, ErrLevel, ErrNum, ErrMessage, szErrMessage)

    ByVal hInst        As Long
          ErrLevel     As Integer
          ErrNum       As Long
    ByVal ErrMessage   As String
    ByVal szErrMessage As Integer

Parameters

hInst | Essbase VB API instance handle.
ErrLevel | Pointer to variable to receive message level.
ErrNum | Pointer to variable to receive message number in the message database.
ErrMessage | Buffer to receive a message string.
szErrMessage | Size of the buffer to receive a message string.

Return Value

If successful, returns a pointer to a message level, a pointer to a message number, and a message string. Also decrements internal message stack pointer.

Notes

- Message stack is being initialized every time a VB API function is called. All messages from the previous call are lost.
- All messages including information, warning, and error messages go into the message stack.
- If the number of messages generated during one VB API function call exceeds the setting in ErrorStack from ESB_INIT_T (or default) new messages overwrite old messages.
- If no more messages in the stack Message is reset to empty string, pNumber and pLevel are reset to zero.
- If the message string length is greater that the size of the buffer, the message is truncated.

Access

This function requires no special privileges.

Example

    Declare Function EsbGetMessage Lib "ESBAPIW" (ByVal hInst As Long, ErrLevel As Integer, ErrNum As Long, ByVal Message As String, ByVal szMessage As Integer) As Long
    Sub ESB_GetMessage ()
       Dim Items As Integer
       Dim AppName As String
       Dim DbName As String
       Dim FilterName As String
       Const szMessage = 256
       Dim Message As String * szMessage
       Dim Number As Long
       Dim Level As Integer
       Dim sts As Long

       AppName = "Demo"
       DbName = "Basic"
       FilterName = "Filter"

       '****************
       ' Get Filter List
       '****************
       sts = EsbGetFilterList (hCtx, AppName, DbName,
        FilterName, Items)

       '*******************************
       ' Process all messages if error
       ' occurred till the bottom of the
       ' message stack enItemsered
       '*******************************
       If sts > 0 Then
          sts = EsbGetMessage (hInst, Level, Number,
                Message, szMessage)
          Do While Mid$(Message, 1, 1) <> Chr$(0)
             Print Level
             Print Number
             Print Message
             sts = EsbGetMessage (hInst, Level,
                   Number, Message, szMessage)
         Loop
       End If
    End Sub

See Also

EsbAutoLogin()
EsbInit()