Visual C++

Borland C++ Builder

 

Adding uCalc to your C++ application

 

There currently are headers for C++ Builder and VC++.  For VC++, the headers are designed to work either with Unicode, or Multi-Byte character set.  There are separate headers depending on whether you need 64-bit or 32-bit, MFC, Native, or .NET.

 

Console programs in VC++

 

If you want to create a console program in Visual C++ that uses uCalc, then from the menu go to File / New / Projects and select Win32 Console Application.  After choosing the location for your project directory, select a name for the project and click OK.  Example:

 

#include "stdafx.h"

#include "uCalcVC.h"

#include <string>

#include <iostream>

 

int _tmain(int argc, _TCHAR* argv[])

{    

      string Input = "";

      while (Input != "0") {

            cout << "Enter an expression (type 0 to stop):  ";

            cin >> Input;

            cout << "Result: " << ucEvalStr(Input) << endl << endl;

      }

     

      return 0;

}

 

Console programs in VC++ with MFC

 

      while (CString_Input != "0") {

            cout << "Enter an expression (type 0 to stop):  ";

            scanf("%s", char_Input);                       

            CString_Input = char_Input;

            cout << "Result: " << ucEvalStr(char_Input) << " (using char) " << endl;

            cout << "Result: " << ucEvalStr(CString_Input) << " (using CString) " << endl << endl;

      }

 

 

.NET program

See the demo program in uCalcFMP\VisualCPP\uCalcDemo_NET.

 

Standard Call convention

 

It is very important to remember to always use the _stdcall directive in your callback functions.  Or, you may configure StdCall as the default setting for your compiler.  Here are some examples:

 

DWORD _stdcall MyErrorHandler(long t) // Error handling routine

void _stdcall MyArea(DWORD Expr) // Native callback routine

long double _stdcall MyEasyCallback(double a, long& b, byte c) // Non-native callback

 

 

Examples:

 

The following examples are for key features that may have some peculiarities in C++.  There are many more examples in Visual Basic that are general enough that a C++ counter-part was not included.  C++ Builder examples that are close enough to Visual C++ are done only in C++ Builder.

 

Visual C++

Example 1:  Simple evaluation using ucEvalStr

Example 2:  Fast evaluation millions of times in a loop

Example 3:  A native string callback function

Example 4:  A non-native callback

Example 5:  Strings in non-native functions

Example 6:  Attached variables

 

C++ Builder

Example 1:  Simple evaluation using ucEvalStr

Example 2:  Fast evaluation millions of times in a loop

Example 3:  Defining a centralized error handler

Example 4:  Raising an error with ucRaiseErrorMessage

Example 5:  A native callback function with two numeric arguments

Example 6:  A native callback function with any number of arguments

Example 7:  A native string callback function

Example 8:  A non-native callback

Example 9:  Strings in non-native functions

Example 10:  Attached variables

 

See More Examples

 

New or enhanced in version 3.0

·         You no longer have to worry about whether to compile with Unicode.  Nor do you have to worry about the numeric type.

·         See also What’s New.

 

New or enhanced in version 2.96

 

New or enhanced in version 2.9+

 

Issues for users migrating from version 2.0