<< Return to Main Index

< Return to Class Index

CGXWorksheetFunctions::LookupFunction

virtual gxKeyword* LookupFunction(LPCTSTR text) = 0;

text

A string with the function name.

Return Value

Returns a pointer to the keyword entry; NULL if the function name could not be found.

Remarks

This virtual method is called from the formula engine to search for a function. You should override this methode in your derived class and return Lookup(text, fn_table, sizeof(fn_table));

Example:

class CGXDefaultWorksheetFunctions: public CGXWorksheetFunctions
{                                
public:
   // Constructor
   CGXDefaultWorksheetFunctions();

   // Lookup
   virtual gxKeyword* LookupFunction(LPCTSTR text);

   // Attributes (keyword table table)
   static gxKeyword fn_table[];
   static int fn_table_size;
};

gxKeyword* CGXDefaultWorksheetFunctions::LookupFunction(LPCTSTR text)
{
   // Override this methode in your derived class and
   // return Lookup(text, fn_table, sizeof(fn_table));
   // (see CGXAllWorksheetFunctions::Lookup as an example)

   return Lookup(text, fn_table, fn_table_size);
}

gxKeyword CGXDefaultWorksheetFunctions::fn_table[] =
{
   {_T("@"), _gx_fn_indirect, 0, 0, GX_TC_RANGE, 1,
      {{GX_TC_STRING, STRICT, GX_REQUIRED}
   }},
   {_T("ABS"), _gx_fn_abs, 0, 0, GX_TC_NUMBER, 1,
      {{GX_TC_NUMERIC, STRICT, GX_REQUIRED}
   }},
   {_T("ACCRINT"), _gx_fn_accrint, 0, 0, GX_TC_NUMBER, 7,
      {{GX_TC_NUMERIC, STRICT, GX_REQUIRED},
      {GX_TC_NUMERIC, STRICT, GX_REQUIRED},
      {GX_TC_NUMERIC, STRICT, GX_REQUIRED},
      {GX_TC_NUMERIC, STRICT, GX_REQUIRED},
      {GX_TC_NUMERIC, STRICT, GX_REQUIRED},
      {GX_TC_NUMERIC, STRICT, GX_REQUIRED},
      {GX_TC_NUMERIC, STRICT, OPTIONAL}
   }},
};

int CGXDefaultWorksheetFunctions::fn_table_size = sizeof(fn_table);

See Also

CGXWorksheetFunctions::Lookup

CGXWorksheetFunctions

Class Overview | Class Members