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

Returns variable by name or nil, if variable does not exist.

Pascal
property VarByName: TVarByNameIndexer;

Use parser to evaluate the "(2*i*z)" formula where z=-2+3*i.

uses MtxParseExpr, MtxParseClass; procedure Example(MyParser: TMtxExpression); var z: TValueRec; res: TCplx; begin // 1. Add formula, MyParser.AddExpr('2*i*z'); // 2. Get defined variables z := MyParser.VarByName['z']; // 3. Specify their type z.DefineComplex; // 4. Set values z.ComplexValue := Cplx(-2,3); // or z.ComplexValue := '-2 + 3i'; // 5. Evaluate res := MyParser.EvaluateComplex; // res = -6-4*i Caption := CplxToStr(res); end;
Examples on GitHub
Copyright (c) 1999-2025 by Dew Research. All rights reserved.
What do you think about this topic? Send feedback!