Try Math ParserTable of ContentsVB Example
bcParserX COM Component and DLL

Easy to use with Visual Basic, Visual C++ bcParserX is a 32 bit and 64 bit COM component to parse and evaluate math formula given as string at runtime.

This COM component resides in bcParser.dll which can typically be used from Visual Basic, Visual C++, .NET and other COM enabled environments. The DLL also exports C style functions that wrap the COM component to be used as a classic DLL. Source code is optional and was tested to with Visual C++ 6, Visual Studio.NET (2002), 2003, 2005 or 2008, 2010.

For newer .NET applications we recommend bcParser.NET the Math Parser for .NET. While bcParserX COM component works with .NET, it is better suited for older applications that use COM technologies. Typical users are 32 bit Visual Basic 6 and Visual C++ 6 programs. C Programs can also use bcParserX.dll as a plain old DLL by calling C functions instead of explicitly using the COM interface.

Math Expression Parser COM Component

BCPARSERLib.Parser COM Component and DLL features include:

  • Easy to use, simple component API.
  • Comes with predefined functions.
  • You can create custom functions/variables and get a callback to your functions that you define in your source code.
  • Optimization: Constant expression elimination for repeated tasks.
  • Operators: +, -, /, *, ^
  • Logical Operators: <, >, =, <>, >=, <=, &, |, ! [IF(condition,case1,case2) is supported]
  • Paranthesis: (, {, [
  • Functions in the form of: f(x), f(x,y), f(x,y,z), f(x1, x2, ..., xN)
  • List of predefined functions is available in the documentation.
  • Royalty free distribution.
  • C++ Source code is optional.
  • BCPARSERLib.Parser math parser library is especially useful in scientific, engineering programs as well as financial spread sheet implementations.

    Itís internal arithmetic uses Ďlong double' storage for floating point numbers and has high precision.

  • Purchase and Download
  • Download evaluation version of bcParserX
  • Visual Basic Example (Using as COM Component)
  • Visual Basic.NET 2008 Example
  • Visual C++ COM Example (Using as COM Component)
  • Visual C++ DLL Example (Using as a DLL calling C functions)
  • C# Example (Using COM Component from managed code)
  • Managed C++ Example (Using COM Component in managed C++)
  • Sample screen shots from a Visual Basic application:

    A sample expression

    Accurate error reporting:

    Can point to the error

    GetInvalidPortionOfExpression function allows you to conclude whether you need to define a variable on the fly or not: (Solves cases where the names of variables are not known ahead of time)

    Can detect invalid portion of expression


    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))
    SUM(X,Y,3,4)
     

    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,3,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

    To be efficient in repeated calculations, parser creates a parse tree at first 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 constant branches.

    BCPARSERLib.Parser COM Component can typically be used with Visual Basic, Delphi, C++ Builder, Visual C++ and other COM/ActiveX clients and plain C applications that can call DLL functions. We have tested it with Visual Basic and Visual C++.

    Parser comes with a help file for reference and a Visual Basic demo application for aid in getting started.

    You can download a trial version of  bcParserX COM Component here [Windows Installer msi file 780KB], Visual Basic sample application here. (Trial version of the component must be installed before sample application can be executed, so that it can find and use the component.)

    Installation file contains the the bcParser.dll, license agreement, a help file and a demo Visual Basic 6 project. Component files will be copied into a directory of your choice - <Program Files>\bcParserX by default. You can uninstall these files from Add/Remove Programs option of your Control Panel any time.

    Help file is available for separate download for quick review[45KB]Download Help File
    Help file is targeted mainly for Visual Basic users.

    Here are some Visual Basic instructions on how to get started using your component in Visual Basic.

    Here is a Visual C++ code sample that uses the Parser COM component via vtable (early binding).

    Here is a Visual C++ Console Application that uses the bcParser.DLL component via the functions exported from the DLL.

    Software License for your review.

    Purchasing bcParserX Math Parser COM Component

    You can pay with credit card and download bcParserX Math Parser COM Component immediately from our online store for only $19.95 (With source code 39.95). 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.

    Online Order Form

    For technical questions please contact support@bestcode.com

    A screen shot from Visual Basic Object Inspector:

    Details for Visual C++ Developers:

    BCPARSERLib.Parser is a light weight component (140KB DLL size) written using ATL in C++. The component is APARTMENT THREADED. It is inprocess server and it does not support aggregation.

    This component is an ideal choice for Visual Basic, .NET and Visual C++ programmers. It can be used in other languages that have COM support as well. Component implements IDispatch interface and can be used from scripting environments such as ASP (Active Server Pages). Visual C++ Developers should prefer early binding using the vtable instead of using IDispatch. Note that the VC++ Class Wizard creates code that runs slow using IDispatch. Please, refer to our early binding sample instead.

    If you buy the source code, you can compile it with Visual C++ 6.0 or Visual C++.NET. It is possible to shrink the DLL size to ~50KB if you donít mind dynamically linking to MS runtime libraries. Current size is based on minumum dependency settings so that it can be deployed without any worries.

    Click here for WindowsCE Pocket PC - HOW TO

    If you wish to compile for mobile platforms, there are few issues.

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

     

    Here is a sample MFC application displaying the parser result:

    Details for C Developers:

    bcParser.DLL exports various functions that can be called by a C application. These functions are wrappers around the actual COM component. COM subsystem in Windows must have been initialized using CoInitialize() method before the COM component can be used. (Refer to the C example) The rest is C business as usual. If the COM component is not installed (not registered), then the first C call to CreateParser() function will register the component.

    Functions that work with character arrays have 2 versions, _UNICODE versions end with W. bcParserDLL_unicode.h defines necessary macros to make it possible to write portable code that will compile regardless of _UNICODE setting.

    There is a Visual C++ 6.0 bcParser.lib that can be used as an import library for the DLL.

    Purchasing bcParserX Math Parser COM Component

    You can pay with credit card and download bcParserX Math Parser COM Component immediately from our online store for only $19.95 (With source code 39.95). 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 licenses can be purchased here .

    Online Order Form

    For technical questions please contact support@bestcode.com

    Math Parser Online Store - Math Parser Site License

    webmaster@bestcode.com