function DefineDouble(const AVarName: string): TDoubleValue;
Defines new double variable.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | AVarName | string |
Returns: TDoubleValue
Remarks:
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.
Examples
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;
See Also: TMtxExpression.Undefine, TMtxExpression.VarByName, TMtxExpression.GetVarList, TMtxExpression.DefineVariable, TMtxExpression.DefineComplex, TMtxExpression.DefineVector, TMtxExpression.DefineMatrix, TMtxExpression.DefineFunction, TMtxExpression.DefineVaryingFunction, TMtxExpression.DefineOperator, TMtxExpression.DefineDoubleConstant, TMtxExpression.DefineComplexConstant