This article was brought to you by the guys from VDF-GUIdance.
For more DataFlex targeted articles see http://www.vdf-guidance.com


Business Calculator

by Sergey V Natarov

Summary

This package contains a business calculator that can be easily included in your programs.
Size: 90 KB Download
Date Created: 16/02/2000
Date Updated: 10/03/2002
Author: Sergey V Natarov
Company: SCR


Business Calculator (rev. 1.0.5 Beta)
"It may be better, than Excel!" %-)
Here's a screenshot of the business calculator in action.

Overview...

This Calculator was created for Business applications.

This is a simple, but very powerfull tool.
Package Info:
==================================================================
Name of component.. Business Calculator
Internal Revision.. 1.0.5b
Author............. Sergey V. Natarov
Company............SCR, 1998 - 2000
Language........... Eng
Date of Changes.... 16/02/2000 (February 16, 2000)
Component Type..... Dialog
File Name.......... Calctr.dg
VDF Revision....... VDF 6.0 (Compiled & Tested)
VDF IDE............ IDE 6.00.14
Package Compressed with WinZip 6.3.
History:
Legend: + added,
- removed,
  • updated.

History:1.0.5b:

* Updated the code to VDF6 and VdfQuery 1.3b
+ Added support to invoke the calculator from the toolbar.

History:1.0.4b:

+ Graph representation of history list
+ Auto filling of History List with pointed values
+ Convert History List values to numeric values (NUM)
+ Set Memory cells on loading History List
+ User defined buttons for History List (array processing)

History:1.0.3b:

+ Simple/Advanced Mode of Calculator,
+ Source code optimization,
+ Input from keyboard,
+ Function "Average" in Array Calculations,
* Calculator's components redesigned,
- Fixed some bugs,
+ Added new bugs :-).

Main Futures:

* Support basic operations [+-/*],
* Percent computations [267 -25%],
* Simple/Advanced Mode,
* Math Functions support [Sin,Cos,Tan,Sqrt,1/x,^2,n!,Rnd,Log,Exp,Abs],
* Pi embedded as constant [3,1415926...],
* Two memory cells support [M,M1],
* All ariphmetic calculations with memory cells [+-/*],
* Result window supports both results of operations and
Expressions Entry [ (25+56)-32... ],
* Current Operation Indicator Window,
* History List [History,Save,Load,Calculate,Delete,Import,Sort,Graph,
Min,Max,Ave,Num,Fil,Custom Actions,Buttons define].
At present does not work "Import" button.

Computations of percents.

1. Simple Calculations

- Input value,
- press '%',
- input percent value,
- press '='
(find percent from value)

2. Operations with procents:

- Input value,
- press +/-*,
- press %,
- press value of percent,
- press =
(Its looks like 100 - 25% = 75)

History List.

All operations with calculator are stored in "History List". So, any
calculated value can be imported to Result Window. Operations like
SIN/COS... are inserted in History List as "Sin(25)=123456", but import
works only with results (123456).
Also, you can use History List as unlimited additional memory cells
for sub totals.
You can save/load your results with History List. All data are stored
in file "calctr.hst". Now you can start your calculations and finish
it later. History file is a usual ASCII file. Strings with '#' sign
responsed as comments. You can create such file and load it in this
calculator.
If you have some values in memory cells, History List will save it
in history file on "Save" action:
Set Memory To 123,45
Set Memory1 To -321,45
To define Custom buttons for stream array processing, please insert
in History file (Calctr.hst) following lines:
Set Label_Of_UDB1 To "Button 1 Label"
Set Action_Of_UDB1 To "(Expression)"
You can define up to 3 custom buttons (UDB1, UDB2, UDB3).
Also, you can define new labels for standard buttons:
Set Label_Of_NUM To "Label"
Set Label_Of_AZ To "Label"
Set Label_Of_ZA To "Label"
Set Label_Of_MIN To "Label"
Set Label_Of_MAX To "Label"
Set Label_Of_AVE To "Label"
Set Label_Of_FIL To "Label"
Set Label_Of_GRP To "Label"
Set Label_Of_SUM To "Label"
(Expression) must be standard VDF expression like "((21*5)-12)". To
detrminate values from array, please insert "@_" signs at your
expression:
"((1*@_)-2)".

Example:

If you have in the History List: 1, 2, 3... The Custom Button will work
as:
1: ((1* 1 )-2) = -1
2: ((1* 2 )-2) = 0
3: ((1* 3 )-2) = 1
After pressing of button, the History List will be: -1, 0, 1...
Remember! Empty string and strings with "#" at any point are ignored!

Example:

# Our budget for September, 1999

# Stuff's Salary:
456636,77

# Office Rent:
235235,23

# Equipment:
2354235,44

# End of Budget
You can Add any specific constant in History List. Input any constant
to Result Window, then press "Enter". Inputed value will be stored
in History List like: (-12345,67)=-12345,67. This result you can use
later for calculations.
History List has a second function. You can use this list for array
calculations. So,
1. Press 'Clear' button, if History List has some entries,
2. Click on the body of History List to Activate him,
3. Input value and press 'Enter',
4. Input new value and press 'Enter' again,
....
Press 'SUM' button:
11<Enter>
11<Enter>
11<Enter><SUM>
Result Window: [33].

History List operations:

"Save" - Save current content of History List
"Load" - Load saved content of History List
"Delete" - Delete current row in History List
"Clear" - Delete current content (clear) of History List
"Import" - Import current row to Result Window of Calculator
"Button" - Dialog for defining buttons

"NUM" - Convert all entries of History List to numeric values
"A-Z" - Sorting numeric values for ascending
"Z-A" - Sorting numeric values for descending
"MIN" - Find minimal value of array
"MAX" - Find maximal value of array
"AVE" - Find average value of array
"SUM" - Find a summ of array values
"GRP" - Array graphical representation
"FIL" - Fill array with specific values [from, to, step, f(x)]

Known bugs in this beta: :-(Help me, pls!

- Does not work "Import" Button. I can't determinate the invoking onject. Prior_Level, when chain Calculator from
Any field, has ID=0.
- Incorrectly work "," key, when input from keyboard.
I do not know: what physical key name for "," (like KEY_PLUS).
Enjoy with my job,
I'm wait any (bad or good) comments, ideas, help...
Best Regards,
Sergey V. Natarov

Following are the steps needed to include this package into the order entry example

- Copy the files Calctr.dg, Calctr.hst, cGraphu.pkg, dfcalcbtn.pkg, Fillhl.dg, udpinp.dg into the order\appsrc folder
- Copy Calctr.bmp to the order\bitmaps folder.
- Open the IDE in the order entry sample workspace
- Select 'Register external component' from the 'Components'-menu
- In the dropdown box select a tool-bar object
- Now click on the prompt button of item package name and select the file dfcalcbtn.pkg. This will throw up a errorbox that complains about an incompatible fileformat that you will not be able to visually edit this package in the IDE. This is perfectly allright, so hit the Ok button on this errorbox.
- Enter 'Calculator toolbar' in the description field and press the <Enter> key. The external component registratioin is complete and now you are ready to include it into the application.
- Open the program 'order entry sample appplication'.
- In the treeview on the lefthand side click on 'Standard toolbar (DfStdBtn.pkg)' and after that select the button 'Change toolbar'. This wil
Object ProgramWorkspace is a Workspace
Set WorkspaceName to CURRENT$WORKSPACE
Set ModuleName to 'Order'
Set HelpName to 'OrdEntry.hlp'
End_Object

Use Help_Ids.inc Developer should provide this file of help context links.
Use Std_Help.pkg
Use Calctr.dg

Notes:

- We advise you strongly not to use the files vdfgraph.utl and strings.utl that are included in the zipfile. These files are taken from the current version of vdfquery 1.3b2. Instead set up your makepath for the compiler to include the vdfquery files from your vdfquery folder. (In the IDE: File -> Configure -> Workspaces tabpage -> Add the path to top of the listbox on the righthand side.
This will guard you from hard to find problems due to changes in future vdfquery updates.

Previous versions

Calculator Version 1.0.5b (83 kB)