Frequently Asked Component Specific Questions

Options

Display all FAQ items

Search FAQ items:


Displaying items 1 to 1 of 1, page 1 of 1

<< previous next >>

TAdvSpreadGrid
Using the expression parser / evaluator

The expression parser / evaluator of TAdvSpreadGrid, our spreadsheet component , can also be separately used. This expression evaluator is in the unit AdvFormula.

To use it, create an instance of the class TAdvFormula and it can be used in the following way:

var
  Fm : TAdvFormula;
  R: double;
begin
  Fm := TAdvFormula.Create(self);
  try
    Fm.Expression := ''1+2'';
    if Fm.Calc(r) then
       showmessage(floattostr(r));
  finally
    Fm.Free;
end;
The expression parser / evaluator also has 100 internal variables (V0..V99) and this can be used in the following way:

var
  Fm : TAdvFormula;
  R: double;
begin
  Fm := TAdvFormula.Create(self);
  try
    fm.v[0] := 12;
    fm.v[1] := 25;
    Fm.Expression := ''V0+V1'';
    if Fm.Calc(r) then
       showmessage(floattostr(r));
  finally
    Fm.Free;
  end;
end;