# EsbBeginCalc

Description

EsbBeginCalc() starts sending a calc script and optionally executes it against the active database. This call must be followed by successive calls to EsbSendString() to send the calc script, and finally by a call to EsbEndCalc(). The Calc Script must be less than 64 KBytes long in total. The calculation can either be initiated, or the calc script can just be verified and any errors returned.

Syntax

    EsbBeginCalc (hCtx, isCalculate)

    ByVal hCtx        As Long
    ByVal isCalculate As Integer

Parameters

hCtx | Essbase VB API context handle.
isCalculate | Controls calculation of the calc script. If TRUE, the calc script is executed.

Return Value

None.

Notes

- 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 EsbBeginCalc Lib "ESBAPIW" (ByVal hCtx As Long, ByVal Calculate As Integer) As Long
    Sub ESB_BeginCalc ()
       Dim sts As Long
       Dim Script As String
       Dim Calculate As Integer
       Dim ProcState As ESB_PROCSTATE_T
       Script = "CALC ALL;"
       Calculate = ESB_YES
       '***********
       ' Begin Calc
       '***********
       sts = EsbBeginCalc (hCtx, Calculate)
       '***********************
       ' Send Calc script
       '***********************
       sts = EsbSendString (hCtx,Script)
       '*********
       ' End Calc
       '*********
       sts = EsbEndCalc (hCtx)
       '************************************
       ' Check process state until it is done
       '************************************
       sts = EsbGetProcessState (hCtx, ProcState)
        Do Until ProcState.State = ESB_STATE_DONE
          sts = EsbGetProcessState (hCtx, ProcState)
       Loop
    End Sub

See Also

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