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

Defines new complex variable.

Pascal
function DefineComplex(const AVarName: string): TComplexValue;

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 "(2*i*z)" formula where z=-2+3*i.

uses MtxParseExpr, MtxParseClass; procedure Example(MyParser: TMtxExpression); var z: TComplexValue; res: TCplx; begin // 1. Define variables z := MyParser.DefineComplex('z'); // 2. Set values z.ComplexValue := Cplx(-2,3); // 3. Add formula and evaluate, MyParser.AddExpr('2*i*z'); res := MyParser.EvaluateComplex; // res = -6-4*i end;
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!