# EssOtlGetMemberLastFormula

Description

EssOtlGetMemberLastFormula() returns the last formula used to calculate the member.

Syntax

    ESS_FUNC_M EssOtlGetMemberLastFormula (hOutline, hMember, ppszFormula);

ESS_HOUTLINE_T | hOutline
ESS_HMEMBER_T | hMember
ESS_PSTR_T | ppszFormula

Parameters

hOutline | Outline context handle
hMember | Member handle.
ppszFormula | Variable for the return of the member formula. This buffer is allocated by the API.

Return Value

The return value is zero if the function was successful.

Notes

- Use EssFree() to free the formula buffer.
- This call will work for both EssOtlOpenOutline() and EssOtlOpenOutlineQuery().
- EssOtlGetMemberLastFormula() returns the last formula applied to the selected member, which might differ from the Database Outline formula associated with that member.
- The last formula is derived from the last calculation (either from the outline or calc scripts) done on the member.

Example

    #include <ESSAPI.H>
    #include <ESSOTL.H>

    ESS_STS_T          sts = 0 ;
    ESS_HOUTLINE_T     hOutline;
    ESS_OBJDEF_T       Object;
    ESS_APPNAME_T      szAppName;
    ESS_DBNAME_T       szDbName;
    ESS_OBJNAME_T      szFileName;
    ESS_HMEMBER_T      hMember;
    ESS_STR_T          pszFormula = ESS_NULL;

    memset(&Object, '\0', sizeof(Object));
    Object.hCtx = hCtx;
    Object.ObjType = ESS_OBJTYPE_OUTLINE;
    strcpy(szAppName, "Sample");
    strcpy(szDbName, "Basic");
    strcpy(szFileName, "Basic");
    Object.AppName = szAppName;
    Object.DbName = szDbName;
    Object.FileName = szFileName;

    sts = EssOtlOpenOutline(hCtx, &Object, ESS_TRUE,
          ESS_TRUE, &hOutline);

       if (!sts)
       {
           sts = EssOtlFindMember(hOutline, "Margin", &hMember);
       }

       if (!sts && hMember)
       {
           sts = EssOtlGetMemberLastFormula(hOutline, hMember, &pszFormula);
                 printf("Member Last Formula: %s\n",pszFormula);
       }

       if (pszFormula)
       {
           EssFree(hInst, pszFormula);
       }

See Also

EssFree()
EssOtlDeleteMemberFormula()
EssOtlGetMemberFormula()
EssOtlOpenOutline()
EssOtlOpenOutlineQuery()
EssOtlSetMemberFormula()