Example #1
0
double GetSymbolFromDll(const int chair, const char* name, bool& iserr)
{
	int			e = SUCCESS, stopchar = 0;
	double		res = 0.;
	CString		str = "";
	tpi_type	tpi;
	bool		result = false;
	CGrammar	gram;

	str.Format("%s", name);

	result = gram.ParseString(&str, (const SFormula *) p_formula, &tpi, &stopchar);

	if (result)
	{
		e = SUCCESS;
		res = gram.EvaluateTree(p_formula, tpi, NULL, &e);
	}
	else
	{
		res = 0;
		e = ERR_INVALID_FUNC_SYM;
	}

	if (e == SUCCESS)
		iserr = false;

	else
		iserr = true;

	return res;
}
Example #2
0
extern "C" __declspec(dllexport) double __stdcall GetSymbolFromDll(const int chair, const char* name, bool& iserr)
{
    int			e = SUCCESS, stopchar = 0;
    double		res = 0.;
    CString		str = "";
    tpi_type	tpi;
    bool		result = false;
    CGrammar	gram;

    str.Format("%s", name);

    if (strcmp (str, "cmd$recalc") == 0)
    {
        // restart iterator thread
        if (p_symbol_engine_prwin->nopponents_for_prwin() == 0)
        {
            iter_vars.set_iterator_thread_complete(true);
        }
        else
        {
            p_iterator_thread->RestartIteratorThread();
        }

        // Recompute versus tables
        p_versus->GetCounts ();
        iserr = false;
        return 0;
    }

    result = gram.ParseString(&str, (const SFormula *) p_formula, &tpi, &stopchar);

    if (result)
    {
        e = SUCCESS;
        res = gram.EvaluateTree(p_formula, tpi, NULL, &e);
    }
    else
    {
        res = 0;
        e = ERR_INVALID_FUNC_SYM;
    }

    if (e == SUCCESS)
        iserr = false;

    else
        iserr = true;

    return res;
}
Example #3
0
bool CFormula::ParseLoop(const CUPDUPDATA* pCUPDUPData)
{
	int				i = 0, j = 0, N = 0;
	CString			s = "";
	bool			result = false;
	int				stopchar = 0;
	int				c = 0, linenum = 0, colnum = 0;
	LARGE_INTEGER	bcount = {0}, ecount = {0}, lFrequency = {0};
	double			time_elapsed = 0.;
	sData			*data = (sData*) (pCUPDUPData->GetAppData());
	CGrammar		gram;

	pCUPDUPData->SetProgress("", 0, false);

	// init timer
	QueryPerformanceCounter(&bcount);
	QueryPerformanceFrequency(&lFrequency);

	N = (int) data->pParent->formula()->mFunction.GetSize();
	for (i=0; i<N; i++)
	{

		// Update progress dialog
		s.Format("Parsing formula set %s : %.0f%%", data->pParent->formula()->mFunction[i].func.GetString(), (double) i / (double) N * 100.0);
		QueryPerformanceCounter(&ecount);
		time_elapsed = ((double) (ecount.LowPart - bcount.LowPart))/((double) lFrequency.LowPart);
		pCUPDUPData->SetProgress(s.GetString(), (int) ((double) i / (double) N * 100.0), time_elapsed>=3.0);

		// Parse it if it is dirty, and not notes, dll or f$debug
		if (data->pParent->formula()->mFunction[i].dirty == true &&
				data->pParent->formula()->mFunction[i].func != "notes" &&
				data->pParent->formula()->mFunction[i].func != "dll" &&
				data->pParent->formula()->mFunction[i].func != "f$debug")
		{
			result = gram.ParseString(
							&data->pParent->formula()->mFunction[i].func_text, 
							data->pParent->formula(), 
							data->pParent->set_tpi(i), 
							&stopchar);

			if (!result)
			{
				linenum = colnum = 1;
				for (c=0; c<stopchar; c++)
				{
					if (data->pParent->formula()->mFunction[i].func_text.Mid(c, 1)=="\n")
					{
						linenum++;
						colnum = 1;
					}
					else
					{
						colnum++;
					}
				}
				s.Format("Error in parse of %s\nLine: %d  Character: %d\n\nNear:\n \"%s\"",
						 data->pParent->formula()->mFunction[i].func.GetString(),
						 linenum, colnum,
						 data->pParent->formula()->mFunction[i].func_text.Mid(stopchar, 40).GetString());
				MessageBox(data->calling_hwnd, s, "PARSE ERROR", MB_OK);
				data->all_parsed = false;
			}

			else if (gram.parse_symbol_stop_strs()->GetSize() != 0)
			{
				s.Format("Error in parse of %s\n\nInvalid symbols:\n",
						 data->pParent->formula()->mFunction[i].func.GetString());
				for (j=0; j<gram.parse_symbol_stop_strs()->GetSize(); j++)
				{
					s.Append("   ");
					s.Append(gram.parse_symbol_stop_strs()->GetAt(j).c_str());
					s.Append("\n");
				}
				MessageBox(data->calling_hwnd, s, "PARSE ERROR", MB_OK);
				data->all_parsed = false;
			}

			else
			{
				data->pParent->set_func_dirty(i, false);
			}
		}
	}

	pCUPDUPData->SetProgress("", 100, true);

	return true;
}