| DataObject::SetFormulaAutoUpdateSetFormulaAutoUpdate DescriptionIt sets the recalculate mode for the formula in the DataObject. To set the mode to the value other than AU_NONE, a formula string must be present in the DataObject. Syntax
BOOL SetFormulaAutoUpdate( int nMode = AU_AUTO )
 
BOOL SetFormulaAutoUpdate(int nBegin, int nEnd, int nMode = AU_AUTO)
 Parameters
    nMode[input] the desired mode. Possible values are:AU_NONE = not recalculable (no operation object present).AU_AUTO = automatic recalculation once any input value changes.AU_ON_COMMAND = manual recalculation.   
    nBegin[input] lower row bound of the formula. 
    nEnd[input] upper row bound of the formula. 
    nMode[input] the desired mode. Possible values are:AU_NONE = not recalculable (no operation object present).AU_AUTO = automatic recalculation once any input value changes.AU_ON_COMMAND = manual recalculation. ReturnTRUE is success, otherwise FALSE. ExamplesEX1 
// Have a worksheet with some formula in the second column.
// column A fill row number, column B set column value with "col(A)" and set recalculate to Auto
void       DataObject_SetFormulaAutoUpdate_ex1(int nMode = AU_ON_COMMAND, int colIndex = 1)
{
    Worksheet   wks = Project.ActiveLayer();
    if ( !wks )
        return;
 
    Column      col = wks.Columns(colIndex);
    if ( !col )
        return;
 
    int    nModeBefore = col.IsFormulaAutoUpdate();
    col.SetFormulaAutoUpdate(nMode);
 
    int    nModeAfter = col.IsFormulaAutoUpdate();
    printf("Before: %d\t After: %d\n", nModeBefore, nModeAfter);
}
EX2 
// Have a Matrix with some formula and set recalculate to Manual
void DataObject_SetFormulaAutoUpdate_ex2()
{
    MatrixLayer ml = Project.ActiveLayer();
    if ( !ml )
    {
        printf("Can not access active matrixsheet");
        return;
    }
    MatrixObject mo = ml.MatrixObjects(0); //get first matrixobject
    int nOldMode = mo.IsFormulaAutoUpdate();
    mo.SetFormulaAutoUpdate(AU_AUTO);
    
    printf("MatrixObject's formula update mode is changed from %d to %d\n", nOldMode, mo.IsFormulaAutoUpdate());
}
EX3 
void    DataObject_SetFormulaAutoUpdate_Ex3()
{
    Worksheet wks;
    wks.Create("origin", CREATE_VISIBLE);    
 
    Dataset dsA(wks, 0);
    dsA.Data(1, 100, 1);    
 
    Column col(wks, 1);
    col.SetFormula("sin(4*col(A)*pi/180)");
    col.SetFormulaAutoUpdate(2, 6, AU_AUTO);
   
    int nBegin, nEnd;
    bool bAU = col.IsFormulaAutoUpdate(&nBegin, &nEnd);
    if(AU_AUTO == bAU)
        out_str("set column formula with auto update mode");
}
RemarkSee Alsoheader to Includeorigin.h |