You are here: Symbol Reference > MtxParseExpr Namespace > Classes > TMtxExpression Class > public > TMtxExpression.DefineDouble Method
MtxVec VCL
ContentsIndex
PreviousUpNext
TMtxExpression.DefineDouble Method

Defines new double variable.

Pascal
function DefineDouble(const AVarName: string): TDoubleValue;

If variable with name AVarName already was definded, it will be redefined and all expressions which contain the symbol AVarName will be recompiled before the next evaluation.

Use parser to evaluate the "Sqrt(X*X + Y*Y)" formula where x=3 and y=4.

uses MtxParseExpr, MtxParseClass; procedure Example(MyParser: TMtxExpression); var x,y: TDoubleValue; res: double; begin // 1. Define variables x := MyParser.DefineDouble('x'); y := MyParser.DefineDouble('y'); // 2. Set values x.DoubleValue := 3.0; y.DoubleValue := 4.0; // 3. Add formula and evaluate, MyParser.AddExpr('Sqrt(x*x+y*y)'); res := MyParser.EvaluateDouble; // res = 5.0 end;
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!