LlExprParse

Syntax:

LPVOID LlExprParse (HLLJOB hJob, LPCTSTR lpExprText, BOOL bTableFields);

Task:

Tests the expression for correctness and constructs a function tree for this expression.

Parameter:

hJob: List & Label job handle

lpExprText: Expression

bTableFields: TRUE: reference to fields and variables FALSE: reference to variables

Return Value:

Pointer to an internal structure (parsing tree)

Hints:

If an error is signaled (Address = NULL) then you can query the error text with LlExprError().

The variables defined with LlDefineVariable() can be integrated into the expression if bTableFields is FALSE, otherwise the fields defined with LlDefineField() are included in the expression.

If the expression is used for calculation several times, it is recommended that you translate it once with LlExprParse() and then carry out the calculations, releasing the tree at the end.

Example:

LPVOID   lpExpr;
char     lpszErrortext[128];
char     lpszBuf[20];
Long     lDateOne;
Long     lDateTwo;

LlDefineVariable(hJob, "Date", "29.2.1964", LL_TEXT);
lpExpr = LlExprParse(hJob, "DateToJulian(DATE(Date))", FALSE);
if (lpExpr)
{
   if (LlExprType(hJob, lpExpr) != LL_EXPRTYPE_DOUBLE)
   {
      // something is wrong, must be numerical!
   }
   LlExprEvaluate(hJob, lpExpr, lpszBuf, sizeof(lpszBuf));
   lDateOne = atol(lpszBuf);
   // lDateOne now has the Julian date  
   // 29.2.1964
   LlDefineVariable(hJob, "Date", "28.10.2017", LL_TEXT);
   LlExprEvaluate(hJob, lpExpr, lpszBuf, sizeof(lpszBuf));
   lDateTwo = atol(lpszBuf);
   // lDateTwo now has the Julian date  
   LlExprFree(hJob, lpExpr);
}
else
{
   // Error!
   LlExprError(hJob, lpszErrortext, sizeof(lpszErrortext));
}

See also:

LlExprEvaluate, LlExprType, LlExprError, LlExprFree