LibMaster.com Extendable Calculator
Usually software calculators imitate hardware calculators. It allows
Users the ability to quickly start their work with a new program, since the
user already knows how to use their hardware calculator. But with this
approach, in regards to the design of software calculators, it inherits all
of the defects of hardware calculators. For example:
- The window of the program is painted in the form of a device with many
unnecessary buttons, and a single indicator for input and output will occupy
a lot of "real estate" on the screen.
- You cannot input expressions for calculations as a formula, for
example:
123.32-12.4/sin(1/2)
Every number, operator, or function must be entered separately, independent
of one another.
Therefore you cannot edit expressions that were previously entered.
For example you cannot calculate:
123.32-12.4/sin (1/2)
and later
123.32-12.2/sin (1/2)
You must enter all of the formula anew because one number is different then
the other.
- Painted buttons provoke heavy mouse usage for input, but it will greatly
reduce input speed of expressions. This is good for calculating, but it does
promote fatigue of hand, due to mouse usage. For the necessary button
search, a need is to permanently reread button captions or remember the last
button location.
- Although it seems that the button is painted a great deal, the
calculator window can contain many buttons (tens of buttons). Not only does
it include many function buttons, but figure buttons and operator buttons.
Therefore most of these calculators have a very limited function set.
- A Single indicator for representation of input expressions will not
allow users to simultaneously see all of their entered formula and
calculation results.
- Every number, operator, or function that is inputted separately at
that priority must be kept in mind. For example, if a calculation is made in
ordinary calculator expression 2+2*2 then result is 8, but if 2*2+2 is
calculated, then the result is 6. Certainly 2+2*2 and 2*2+2 is equivalent.
This is how ordinary calculators provoke errors.
- Usually you cannot input formulas for calculation, but there must
exist a calculation history. Therefore, for proper error mining, you must
recalculate all of the expressions anew.
- Most of these calculators do not allow simple add new functions
(macros). The calculators that do allow add new functions (macros); usually
have some built-in primitive languages for the programming of new functions.
Such a language carries a high learning curve before using. This has the
possibility of becoming a waste of time for learning users, as they are
often disappointed of the penury of the language, since they do not make
necessary use of the functions that are provided, as well as take advantage
of the potential speed of running these functions.
- Practically absent calculators, which have a simultaneous graphic and
console interface. Although the availability of console interface is
irreplaceable for automation processing of big size source data.
The LibMaster.com Extendable Calculator is a different way to approach
calculator design. Therefore it does not contain any of the design defects,
as outlined above.
The Graphical interface of this Extendable Calculator is simple and
handy. It consists of one small window, which may be sized horizontally, and
four combo-box controls. The combo-boxes are made up of:
- "Expression" combo-box control. Edit-box part of this control allows
input of unlimited length formulas. User can work with arithmetical
expressions, brackets, and functions such as "(23+11)*321/2-sin
(1/4)+your_custom_func (32, 123, 32)". If user clicks to the drop-down
button of this combo-box, or presses key they will see a
calculation history. Any formulas can now be selected from the calculation
history for editing or modification.
In addition, user can make their own variables, which maintain their
values during calculator use.
- "Function list". This combo-box control allows users the ability to
see a list of functions which the calculator supports, and that also belong
to selected types in the "Function types" combo-box. After user selects a
necessary function and presses , its name will be added to end of the
formula string, which contains an edit-box part of the "Expression"
combo-box control. If user inputs a function name in the edit-box part of
"Function list" combo-box control, then an auto complete process, beginning
from your typed symbols, will automatically complete your string in
edit-box.
If user places the mouse cursor over the "Function list" combo-box they
will see a hint window, with a short description of the function that is
currently selected.
If "Function list" combo-box has input focus, then pressing the F1 key
will summon a dialog window with detailed description of the function that
has been selected at this time.
- "Function types" - This Calculator has many functions and they will
increase, as the user permits, since the calculator allows the simple
addition of new functions, as well as the ability to add pre-created
functions or, even download new functions from our site.
This combo-box control allows users the ability to view a list of
functions types that has full Calculator support. After the user selects a
necessary function type in "Function types" combo-box, under the "Function
list" combo-box you can see list of all functions of the selected type.
- "Result" - When user inputs their formula into this field and presses
(in the "Result" Combo Box), they will see the result of the
calculation of their formula. In the edit-box part of the view, the result
will be displayed in decimal numeration. If a drop combo-box is used, the
result can be displayed in hexadecimal, octal, binary and exponential
numeration.
The width of the panels, which contain "Function list",
"Function types" and "Result" combo-boxes, can be changed also. This can be
accomplished by positioning the mouse cursor to the vertical boundary
between panels, and when the mouse cursor reshapes form to two arrows,
depressing the left mouse button will allow dragging of the boundary to
wishful side.
The Extendable Calculator is delivered with more than a hundred useful
functions and they will increase, as the user permits. Users can also simply
add new and necessary functions, written in their known programming
language, whereas a compiler can create dynamic-link libraries (DLL) for
using.
Such an approach to the extension of calculator functionality was chosen
not by accident:
- Users do not need to learn new wretched programming language (included
with built-in calculators). If you don't know any programming languages,
then there is a requirement to learn serious universal programming language,
as well as working with a particularized language. Not only that, but most
built-in calculators use scanty documentations.
- Powerful, universal programming languages are projected toward the
best experts in this field and possess the highest functionality.
- Functions written using universal programming languages
Receive access to all computer resources, such as access to local net and
Internet, operations with HDD, other program management processes, as well
as use vital programming libraries.
- Compilers for universal languages are tested by millions programmers
and error probability is vanishing small.
- Functions in the DLL are compiled in machine code, therefore running
as fast as possible, in contrast to calculators with built-in programming
languages where functions are interpreted every time it is used, and speed
of work can be big and complicated, causing very slow performance.
- Users can write functions that use all of the programming libraries
that exist.
- Users can write functions not only for mathematical calculations, but
also for all possible operations. For example, a function can be created
titled "USDCAD", which will return the rate on an American to Canadian
dollar, the rate received from the Internet, or the BALANCE that returned
the demand balance of the account. Afterward, it can be used toward other
calculations.
- If you nevertheless cannot write the necessary functions as desired,
User can describe the necessary functionality to our support team, and our
specialists will make it available for use as soon as possible.
Examples of calculator usage:
Click the calculator icon on Desktop, or Start menu to begin use of the
calculator.
1. Calculation of simple expressions.
If input focus is not in the Expression combo-box - left-click mouse to
the edit-box part of the Expression combo-box field, or move input focus
here using the <Tab> or <Shift+Tab> keys.
Input the expression, for example 22.8+11.123-3 and press <Enter>. In
the Result combo-box, user will see string DEC: 30,923. This is the result
of the calculation in decimal numeration. If the drop-down Result combo-box
is clicked on, the result can be displayed in hexadecimal, octal, binary and
exponential numerations.
Users can edit the "22.8+11.123-3" expression just like the text in any
text editor. Option available are select, cut, copy and past to and from
clipboard, as well as any expressions that are the result of prior
calculations.
Users can input numbers in decimal, hexadecimal, octal, binary and
Exponential numerations. For example:
- Decimal: 300;
- Hexadecimal: 0x12C or $12C or 12Ch;
- Octal: 454o;
- Binary: 100101100b or 0b100101100
- Exponential: 3e2
All letters and numbers can be in lower or upper case.
Expression combo-box, just as other combo-boxes have an Auto-completion
feature. As symbols are inputted, the edit-box part of this field will begin
from previously entered symbols/strings, and the symbols/string will be
added to this field after it is entered.
2. Brackets expressions calculation.
Clear previous expression from edit-box part of Expression combo-box,
and use Delete or Backspace keys. Input expression 2*(7+6*(5+4)) and press
<Enter> In Result combo-box you can see string DEC: 122. User can use
unlimited nesting level of brackets.
3. Calculation of Expressions with using functions.
Select in the "Function list" combo-box function the name that
corresponds to the function required, and press <Enter>. The Name of this
function will be added in the Expression combo-box. Selection of the
function name can be set by two ways:
- If you know the beginning charter(s) of the function name or function
type, but don't know the full name then type known symbols in edit-box part
of combo-box. If this name exists the string will be automatically
completed.
- Select the function type and function name by means of mouse or
keyboard.
For example we need to calculate expression arcsines of 0.5 in radians
and degrees. Type in the Expression combo-box "arcsine (0.5)" and press
<Enter> in the Result combo-box. The string DEC: 0,523598775598299 are the
result of the radians. Edit expression arcsine (0.5) to radtodeg (arcsine
(0.5)) and press <Enter> in the Result combo-box. The string DEC: 30 will
be visible - this is the result in degrees
4. Use of variables.
You can assign symbolic names to a number or expression result.
For that type, for example, var=arcsine (0.5) and press <Enter>.
Now you can use result of arcsine (0.5) expression in any formulas.
For example now you can write "radtoded (var)" and get a result equal to
30.
Variable values are safe all the time while the calculator is running or
while the Value of a variable is not changed.
Name of variable can contain English letters and number only, and the
name of the variable can begin from letter only.
5. Calculation history using.
After you input an expression and press <Enter> the expression can be
saved in calculation history. You can see a sorted list of previously
inputted expressions in the drop-down Expression combo-box, and select any
expression, for editing and recalculation.
6. Adding new functions.
DLL libraries which contained functions for calculator must execute a few
simple rules:
Every DLL library must exports two obligatory functions:
GetFuncCount and GetFuncInfo and also any quantity your defined functions
which you want add to calculator.
All functions which exports from DLL must have calling connvention
of "C" language.
Function GetFuncCount get count of your defined functions which exports
from
your made DLL. This count not include two obligatory functions GetFuncCount and
GetFuncInfo.
Prototype of GetFuncCount function in C or C++ language is:
int GetFuncCount();
Function GetFuncInfo receive index of function which you exports from range
that returning GetFuncCount - 1, that is 0 is the first function index,
1 is the second function index, and so on, and return it descriptions and
pointer to function. Returning value of GetFuncInfo function have BOOL type which
usually defined in C and C++ as typedef int BOOL;
If function correct completed it must return TRUE or 1.
If function incorrect completed it must return FALSE or 0.
Prototype of GetFuncInfo function in C or C++ language is:
BOOL GetFuncInfo(int f,char** fN, char** lD, char** sD, char** fT,
int* fP, FuncT* Fad);
- where:
- f - number of function
- fN - function name
- lD - long description
- sD - short description
- fT - type of function
- fP - count of parametres
- fAd - address of a function
Any user defined function must have following prototype in C or C++
language:
typedef double (*FuncT)(const double*);
Calculator call this function and delivery to it pointer to parameters
array which enter user of calculator. After running function return result as number
of double type.
Below described example of souce code of DLL which add to calculator one
function.
Function my_func have two arguments and return sum of own argumens.
Files with sources for C++ and Delphi you can find in doc\examples
directory (folder)
All functions which are in calculator installation delivered with full
source codes and project files for development environments in which this
functions was made.
C++ header file my_dll.h:
#include
// Define calling convention of "C" language
// and declare attribute that functin exports from DLL
#define DllExport extern "C" __declspec( dllexport )
// Define type of user defined function pointer
typedef double (*FuncT)(const double*);
// Define count of user defined functions in DLL
const int funcCount=1;
// Declare user defined function which exported from DLL
// for adding to calculator
DllExport double my_func(const double* args);
// Declare obligatory functions which exported from DLL
DllExport int GetFuncCount();
DllExport bool GetFuncInfo(int f,char** fN, char** lD, char** sD, char** fT,
int* fP, FuncT* Fad);
//f - number of function
//fN - function name
//lD - long description
//sD - short description
//fT - type of function
//fP - count of parametres
//Fad - address of function
C++ source file my_dll.cpp:
#include "my_dll.h"
DllExport int GetFuncCount() {
return funcCount;
}
//f - number of function
//fN - function name
//lD - long description
//sD - short description
//fT - type of function
//fP - count of parametres
//Fad - address of function
DllExport BOOL GetFuncInfo(int f,
char** fN,
char** lD,
char** sD,
char** fT,
int* fP,
FuncT* Fad) {
if( f < funcCount && f >= 0) {
//function name in input string
*fN="myfunc";
//long description
*lD="this example of function for learning. \n It return sum of two
parameters. \n Using my_func(2, 3)";
//short description
*sD="Example of user defined function.";
//function type: math, temperature conversion...
*fT="custom function";
//count of parametres
*fP=2;
//pointer to function
*Fad=my_func;
return TRUE;
}
else {
return FALSE;
}
}
DllExport double my_func(const double* args) {
return args[0] + args[1];
}
The same example for Delphi:
library my_func_DLL;
type
// Define type of user defined function pointer
FuncT=function(const args:array of double):double;
const
mCountFunc: Integer = 1;
function GetFuncCount():integer; cdecl;
begin
GetFuncCount := 1;
end;
function my_func(const args:array of double): double; cdecl;
begin
my_func := args[0] + args[1];
end;
function GetFuncInfo(f: integer;
var fn, ld, sd, mt: PChar;
var param: integer;
var fa: FuncT): integer; cdecl;
begin
if (f < mCountFunc) and (f >= 0) then begin
//function name in input string
fn := 'myfunc';
//long description
ld := 'this example of function for learning. It return sum of two
parameters. Using my_func(2, 3)';
//short description
sd := 'Example of user defined function.';
//function type: math, temperature conversion...
mt := 'custom function';
//count of parametres
param := 2;
//pointer to function
fa := @my_func;
GetFuncInfo:=1;
end
else begin
GetFuncInfo:=0;
end;
end;
exports
GetFuncCount,
GetFuncInfo;
begin
end.
|