private object pCheckInternalFunction(String functionName, String code)
{
String name = "";
String parameters = "";
csRptFormulaType idFunction = 0;
int r = 0;
int q = 0;
String tc = "";
name = functionName;
parameters = code.Trim();
if (parameters.Length > 2)
{
parameters = parameters.Substring(1, parameters.Length - 2);
}
// we need to replace in m_formula.getTextC() the function name by its key
//
tc = m_formula.getTextC();
q = name.Length;
r = tc.ToLower().IndexOf(name.ToLower(), 0);
q = tc.ToLower().IndexOf(")".ToLower(), r) + 1;
m_formula.setTextC((tc.Substring(0, r)).ToString()
+ C_KEYFUNCINT
+ cReportGlobals.format(m_formula.getFormulasInt().count(), "000")
+ tc.Substring(q));
idFunction = pGetIdFunction(name);
m_fint.setFormulaType(idFunction);
switch (idFunction)
{
case csRptFormulaType.CSRPTFPAGENUMBER:
// in compiling time we need to return a value which is consistent
// with the return type of the internal function
//
if (m_report == null)
{
return 0;
}
else
{
return m_report.getCurrenPage();
}
case csRptFormulaType.CSRPTTEXTREPLACE:
// in compiling time we need to return a value which is consistent
// with the return type of the internal function
//
return "";
case csRptFormulaType.CSRPTFTOTALPAGES:
return m_report.getTotalPages();
// all this functions have the same amount of parameters
//
case csRptFormulaType.CSRPTFAVERAGE:
case csRptFormulaType.CSRPTFSUM:
case csRptFormulaType.CSRPTMAX:
case csRptFormulaType.CSRPTMIN:
case csRptFormulaType.CSRPTLENGTH:
case csRptFormulaType.CSRPTFVAL:
// in this evaluation we load the parameters of the function
//
pCheckParameters(1, parameters, name);
// in compiling time we need to return a value which is consistent
// with the return type of the internal function
//
return 0;
case csRptFormulaType.CSRPTGROUPTOTAL:
case csRptFormulaType.CSRPTGROUPMAX:
case csRptFormulaType.CSRPTGROUPMIN:
case csRptFormulaType.CSRPTGROUPAVERAGE:
// in this evaluation we load the parameters of the function
//
pCheckParameters(2, parameters, name);
// in compiling time we need to return a value which is consistent
// with the return type of the internal function
//
return 0;
// all this functions have the same amount of parameters
//
case csRptFormulaType.CSRPTGROUPCOUNT:
case csRptFormulaType.CSRPTGROUPPERCENT:
// in this evaluation we load the parameters of the function
//
pCheckParameters(3, parameters, name);
// in compiling time we need to return a value which is consistent
// with the return type of the internal function
//
return 0;
case csRptFormulaType.CSRPTFGETSTRING:
// in this evaluation we load the parameters of the function
//
pCheckParameters(1, parameters, name);
// in compiling time we need to return a value which is consistent
// with the return type of the internal function
//
return "\"\"";
case csRptFormulaType.CSRPTFSUMTIME:
// in this evaluation we load the parameters of the function
//
pCheckParameters(2, parameters, name);
// in compiling time we need to return a value which is consistent
// with the return type of the internal function
//
return 0;
case csRptFormulaType.CSRPTCOUNT:
// in compiling time we need to return a value which is consistent
// with the return type of the internal function
//
return 0;
case csRptFormulaType.CSRPTFNUMBERTOSTRING:
// in this evaluation we load the parameters of the function
//
pCheckParameters(2, parameters, name);
// in compiling time we need to return a value which is consistent
// with the return type of the internal function
//
return "\"\"";
// all this functions have the same amount of parameters
//
case csRptFormulaType.CSRPTISEQUAL:
case csRptFormulaType.CSRPTISNOTEQUAL:
case csRptFormulaType.CSRPTISGREATERTHAN:
case csRptFormulaType.CSRPTISLESSTHAN:
case csRptFormulaType.CSRPTISINRS:
// in this evaluation we load the parameters of the function
//
pCheckParameters(2, parameters, name);
// in compiling time we need to return a value which is consistent
// with the return type of the internal function
//
return 0;
// all this functions have the same amount of parameters
//
case csRptFormulaType.CSRPTFCALCULO:
case csRptFormulaType.CSRPTGETDATAFROMRSAD:
case csRptFormulaType.CSRPTGETDATAFROMRS:
// in this evaluation we load the parameters of the function
//
pCheckParameters(4, parameters, name);
// in compiling time we need to return a value which is consistent
// with the return type of the internal function
//
return 0;
// all this functions have the same amount of parameters
//
case csRptFormulaType.CSRPTDECLAREVAR:
case csRptFormulaType.CSRPTGETVAR:
// in this evaluation we load the parameters of the function
//
pCheckParameters(1, parameters, name);
// in compiling time we need to return a value which is consistent
// with the return type of the internal function
//
return 0;
case csRptFormulaType.CSRPTGETPARAM:
// in this evaluation we load the parameters of the function
//
pCheckParameters(1, parameters, name);
// in compiling time we need to return a value which is consistent
// with the return type of the internal function
//
return 0;
// all this functions have the same amount of parameters
//
case csRptFormulaType.CSRPTADDTOVAR:
case csRptFormulaType.CSRPTSETVAR:
// in this evaluation we load the parameters of the function
//
pCheckParameters(2, parameters, name);
// in compiling time we need to return a value which is consistent
// with the return type of the internal function
//
return 0;
default:
throw new ReportNotDefinedFunctionException(
C_MODULE,
cReportError.errGetDescript(csRptErrors.CSRPTERRINDEFINEDFUNCTION,name));
}
}