Skip to main content
Table of Contents

TTMSFNCFilterBuilder.ParseExpression Method

Parses a filter text string and populates the filter structure.

API unit family: TMS.TMSFNCFilterBuilder Declaring type: TTMSFNCFilterBuilder Inherited from: TTMSFNCCustomFilterBuilder

Syntax

TMS.TMSFNCFilterBuilder.hppPascalC++
function ParseExpression(AFilterText: string): Boolean;
bool __fastcall ParseExpression(System::UnicodeString AFilterText);

Parameters

Name Description
AFilterText Filter expression text to parse.

Returns

True when the text was parsed without errors.

Usage examples

Build and apply a typed filter

Combines batched column setup, expression parsing, and row validation.

Build and apply a typed filterPascalC++
uses
  System.SysUtils,
  TMS.TMSFNCFilterBuilder,
  TMS.TMSFNCValue;

var
  LRow: TArray<TTMSFNCValue>;
begin
  TMSFNCFilterBuilder.BeginUpdate;
  try
    TMSFNCFilterBuilder.ClearFilter;
    TMSFNCFilterBuilder.DataColumns.Clear;
    TMSFNCFilterBuilder.AddDataColumn('Status', fdtText);
    TMSFNCFilterBuilder.AddDataColumn('Progress', fdtNumber);

    if not TMSFNCFilterBuilder.ParseExpression(
      '[Status] LIKE ' + QuotedStr('Abroad') + ' AND [Progress] > 50') then
      raise Exception.Create('Invalid filter expression');
  finally
    TMSFNCFilterBuilder.EndUpdate;
  end;

  LRow := ['Abroad', 75];
  if TMSFNCFilterBuilder.ValidateFilterRow(LRow) then
    ShowMessage('The row matches the filter');
end;
TMSFNCFilterBuilder()->BeginUpdate();
try
{
  TMSFNCFilterBuilder()->ClearFilter();
  TMSFNCFilterBuilder()->DataColumns->Clear();
  TMSFNCFilterBuilder()->AddDataColumn("Status", TTMSFNCFilterBuilderDataType::fdtText);
  TMSFNCFilterBuilder()->AddDataColumn("Progress", TTMSFNCFilterBuilderDataType::fdtNumber);

  if (!TMSFNCFilterBuilder()->ParseExpression(
    "[Status] LIKE " + QuotedStr("Abroad") + " AND [Progress] > 50"))
    throw Exception("Invalid filter expression");
}
__finally
{
  TMSFNCFilterBuilder()->EndUpdate();
}

DynamicArray<TValue> LRow;
LRow.Length = 2;
LRow[0] = TValue::From<String>("Abroad");
LRow[1] = TValue::From<int>(75);
if (TMSFNCFilterBuilder()->ValidateFilterRow(LRow))
  ShowMessage("The row matches the filter");

Read the related guide