Math ParserTable of ContentsDelphi Example
TbcParser VCL Component

We all love Delphi & C++ Builder TbcParser is a mathematical expression parser VCL (Visual Component Library) component that can be used with Delphi 4,5,6,7, 2006, 2007, 2009 and C++ Builder 3,4,5,6, 2006, 2009. Source code works with Kylix to compile and run in Linux as well.

TbcParser Component features include:

  • Easy to use component API.
  • Comes with predefined functions.
  • You can create custom functions/variables and get a callback to your own functions that you define in your source code.
  • Optimization: Constant expression elimination for repeated tasks.
  • Analytic Operators: +, -, /, *, ^
  • Logical Operators: <, >, =, &, |, !, <>, <=, >=
  • Paranthesis: (, {, [
  • Functions in the form of: f(x,y,z,...)
  • List of predefined functions is available in the documentation.
  • Royalty free distribution.
  • Source code is included.
  • Figure: Drag Drop on your Delphi or C++ Builder Form as shown below:

    TbcParser math parser library is especially useful in scientific, engineering programs as well as financial spread sheet implementations.

    It’s internal arithmetic uses ‘Extended’ storage for floating point numbers.

    To be efficient in repeated calculations, parser creates a parse tree to represent the math formula and reuses this parse tree for each evaluation without the need to reparse.

    Optimizer: If Optimization is on, the parse tree will be optimized by calculating constant expression sections at once so that further evaluation requests will be quicker without the need to re-evaluate those sub trees.

    TbcParser is tested with Delphi 4, 5, 6, 7, 2006, 2007, 2009 and C++ Builder 3, 4, 5, 6, 2006.

    TbcParser comes with the Pascal source code and there is also a help file for reference and a demo application for aid in getting started. So it is easy to make it work with different versions of Delphi or C++ Builder in the future.

  • Purchase and Download
  • Download evaluation version of TbcParser
  • Delphi Example code
  • C++ Example code
  • Component Installation in C++ Builder
  • Component Installation in Delphi
  • Kylix Demo Screenshot
  • Download Windows Demo Application (EXE, 462KB)
  • Download Windows Demo Application in Zip compressed format (Zip, 238KB)

  • The Math Parser Component is also available on many platforms/languages such as:

    Examples of typical expressions are:

    SIN(3.14)+5^2+POW(2,MAX(X*2,Y))
     

    Functions, variables, constants can be nested.
    Common math functions are defined by default.

    2*[LN(1+X) / LOG(1-X)]
     

    Paranthesis can be (, {, [ for readability.

    IF(X>0, 3/X, F(X))
     

    IF(a,b,c) branching function is supported.

    Boolean operators are supported. Any non-zero value is TRUE, 0 is FALSE.

    Functions can be defined to have 1,2,...N numbers of parameters.

     

    PI*(R^2)

    Constants supported. For example, PI is a constant, not a variable. When optimization is turned on, constants may improve the speed of repeated evaluations where expression does not change but variable values change.

    X+Y/LOG(1+5)
     

    If Optimization is turned ON, LOG(1+5) will be optimized away since it is a constant.

    VOLUME(HEIGHT, WIDTH, LENGTH)
     

    You can create your own functions and variables and name them as you wish.

    You can replace a predefined function with your own implementation.

    X+COSH(3E-2)

    Scientific notation is supported: 3E-2

    You can download a trial version of TbcParser here [Zip file, 402KB]
    Zip file contains the compiled components for Delphi 5,6,7 and C++Builder 5,6. It also contains a demo application and the help file for the component.

    Download ready to run demo application [Exe File 462KB].

    View Delphi Example code.

    Demo Screen Shots:

    This demo application shows examples of the features of the math parser.

    • X and Y are predefined variables (You can undefine them if need be).
    • If the user do not enter valid numbers for X and Y in the GUI, and if the expression does not use them, this application dos not report error, because we can ask the component whether a variable is used and only after that we try to parse the user input.
    • You can enter a name in the Custom Variable edit box and Add your own variable with the specified Value. And then you can use this variable in the expression.
    • You can get a list of currently defined functions and variables as seen in the related combo boxes.
    • Various expression examples, simple and complex are given.
    • Scientific notation is supported (3E-3).
    • IF(condition, case1, case2) and logical operators such as >=, <> etc are supported.

    Below is an example of an error message where it pinpoints the invalid string. This information can be accessed using the EbcParserError.GetInvalidPortionOfExpression function. Most users use this facility to allow their users use any variable they want, and their application catches EbcParserError exception and defines the undefined variable on the fly and proceeds to parse the expression again. This makes it possible to write applications that does not know the variable names ahead of time.

    Error reporting

    As below example shows, a custom variable can be defined and used in the expression. (Custom functions can be defined too). After the variable CUSTOMVAR is created with value 3, the result of the expression is 7 :

    Custom variable defined

    Kylix Application running in Linux:

     

    Help file is available for separate download for quick review[45KB]Download Help File

    Software License for your review.

    Purchasing TbcParser Math Parser Component

    You can pay with credit card and download TbcParser immediately from our online store for only $19.95. Full version includes Pascal source code. Upgrades are free for registered users.
    Licensing is per developer. You can deploy the the component royalty free with your applications as many times as you want. Site license allows any number of developers use the component at your development site. Site License is $159.60. Site licenses can be purchased here.

    Online Order Form

    Sample Screen Shots

    Press Control Wizard is a hardware control application which allows motion profiles to be entered as a mathematical function. Such capability makes it possible to apply theoretical  calculations to reality easily. This application uses an earlier version of the component.

     

    Above Mechanical Engineering application is used to calculate Forging Loads given certain input. One of the inputs required is the Flow Stress of the material being forged and is typically parametric. Below figure shows how the TbcParser Component is used to let the user specify a custom flow stress formula:

     

    Above application was used to calculate tool wear in different machining processes. TbcParser is used to let the user specify material properties such as Flow Stress, Density, Specific Heat, and Thermal Conductivity as a function of temperature through the GUI or from a material database where functions (in string form) are pre-recorded for each material.

     

    For technical questions please contact support@bestcode.com

    Math Parser Online Store - Math Parser Site License

    webmaster@bestcode.com