# EsbCalc

Description

EsbCalc() sends and optionally executes a calc script against the active database as a single string. This function is equivalent to making a call to EsbBeginCalc, followed by calls to EsbSendString(), and finally to EsbEndCalc(). The calculation can either be initiated, or the calc script can just be verified and any errors returned.

Syntax

    EsbCalc (hCtx, isCalculate, cscQuery)

    ByVal hCtx        As Long
    ByVal isCalculate As Integer
    ByVal cscQuery    As String

Parameters

hCtx | Essbase VB API context handle.
isCalculate | Controls calculation of the calc script. If TRUE, the calc script is executed.
cscQuery | The calc script, as a single string (must be less than 64 Kbytes).

Return Value

None.

Notes

- The calc script string must be less than 64 Kbytes long.
- If this function succeeds and the calculation is started, it will continue on the server as an asynchronous process after the return from this call. The caller must check at regular intervals to see if the process has completed by calling EsbGetProcessState() until it returns ESB_STATE_DONE.
- If the Calculate flag is set to FALSE, the database merely performs a syntax check of the calc script.

Access

This function requires the caller to have calc privilege (ESB_PRIV_CALC) to the active database.

Example

    Declare Function EsbCalc Lib "ESBAPIW" (ByVal hCtx As Long, ByVal Calculate As Integer, ByVal Script As String) As Long

    Sub ESB_Calc ()
       Dim sts As Long
       Dim Script As String
       Dim Calculate As Integer
       Dim ProcState As ESB_PROCSTATE_T

       Script = "CALC ALL;"
       Calculate = ESB_YES

       '**********
       ' Calculate
       '**********
       sts = EsbCalc (hCtx, Calculate, Script)

       '************************************
       ' Check process state till it is done
       '************************************
       sts = EsbGetProcessState (hCtx, ProcState)
        Do Until ProcState.State = ESB_STATE_DONE
          sts = EsbGetProcessState (hCtx, ProcState)
       Loop
    End Sub

See Also

EsbBeginCalc()
EsbCalcFile()
EsbDefaultCalc()
EsbEndCalc()
EsbGetDefaultCalc()
EsbGetProcessState()
EsbSendString()
EsbSetDefaultCalc()