FormulaCalc for Ewe
Version 1.1¹
Description
FormulaCalc is a calculator for Ewe enabled computers which accepts algebraic/trigonometric
formulas and computes their values. That is, computes routines.
To learn more about Ewe please read the introduction on the
Bray Mobile Applications page.
The formulas of FormulaCalc:
- Use common algebraic expressions with the normal multiply before add rules.
- Can have up to 26 inputs from stored data.
- Can store results in up to 26 storage locations.
- Can use trigonometric, logarithmic, and other algebraic and control functions.
- Can be input by pen or from a selected file.
It can be used as a simple calculator, or one to compute complicated routines.
We hope you find FormulaCalc useful.
About This Documentation
FormulaCalc is intuitive and easy to use. That seems to be contradicted by the size of this
documentation. It's large because of the many features and functions. But once you become
familiar with FormulaCalc we think you will agree that it is easy to use.
You really
should read this entire document to fully understand FormulaCalc.
For a quick start read Installation and Quick Start.
Then after trying it out please return to this documentation to learn all of the features.
Documentation Sections
Installation
Since you are reading this documentation, you have found that the frmcalc10.zip archive contains
frmcalc10Doc.zip which contains this documentation you are now reading. It also contains
FormulaCalc.ewe, the executable file.
Installation Steps
- Install the the Ewe VM.
- Copy FormulaCalc.ewe to your computer(s).
These two steps are explained next.
- Step 1
- The first thing to do is to install the Ewe VM on your computer(s), if not already
installed. Follow the instruction found on the
Ewe Download and Installation
Page for your computer(s). The Ewe installer will create directories on your
computer and put the Ewe VM files in them.
After Ewe is installed find the Ewe directory. For example, in a Windows Desktop it
will be where you told the installer to install it, and in the Pocket PC it will
(probably) be in \Windows\StartMenu\Programs\Ewe. Specifically, it is the directory in
which you find 'ewe.ewe'.
If you put all of your applications in this directory, when you add additional
applications from Bray Mobile Applications
common files can be shared.
- Step 2
- There is no installer for FormulaCalc.ewe. It can be put in any directory of your
choice. However it is recommended that you put it in the directory with the Ewe VM you
found in Step 1.
Once you find the proper directory copy FormulaCalc.ewe into that directory in what
ever manner you copy files to your computer.
There is also no uninstaller for FormulaCalc. It does not use the operating system
registry, so nothing is hidden. To remove FormulaCalc, simply delete: FormulaCalc.ewe,
and any *.fmc formula files which you created.
Note: No matter what Regional settings are used on your computer(s), FormulaCalc always
uses the '.' (period) as the decimal point, the ',' (comma) as the formula argument and data
separator, and the ";" (semicolon) as the end of formula.
FormulaCalc should be ready to run. Find FormulaCalc.ewe with your File Explorer, click
on it to try it out! Soon after you try out FormulaCalc and find it working, you should read
the Quick Start which follows.
Back to Document Section Links
Quick Start
When you first use FormulaCalc you will be greeted with a display as shown on the right.
The display consists of 5 areas:
- The Menu Header -- the Menu Selector, and the current input source.
- The Input Area -- the clear upper box. The Input Area is also called the Pen
Area.
- The Output Area -- the clear lower box.
- The Button Trailer -- the five control buttons.
The Button Trailer
- Clear -- clears the Output Area (one tap) and Input Area (double tap). The
Clear button is also a way to exit an open window and return to the Input/Output
Area window.
- Compute -- computes the value of the active routine and displays it in the
output area. If you press Compute at first nothing will happen because the
Input Area is empty.
- Reg -- pops up a new window showing the values of the 26 registers A - Z.
The values are changed by tapping a value and modifying it.
- Source -- toggles the active input between the Input Area (i.e. Pen
Area) formulas (i.e. routine) and the routine selected using the Open
button. Pressing this button at will change the active routine and display "Pen Active"
and "Open Routine Active" in the upper right.
- Open -- opens one of the stored routines from a selected formula file. Upon
first tap of Open the 'File Chooser' is opened allowing selection of the desired
file containing FormulaCalc routines. The next time Open is tapped routines from
the same file are displayed, unless the Menu/GetNewFile menu item has been
selected. By convention the formula files are given the file extension of .fmc, but may
be any desired file type (extension).
If you want to use FormulaCalc as a simple calculator:
- Tap the upper left of the Input Area,
- Enter a formula -- e.g. 123 * 4,
- Tap Compute,
- The result is displayed in the Output Area.
Back to Document Section Links
Your First Routine
This is an interactive trial so install FormulaCalc now, and launch it.
In the text which follows, characters which you enter are blue, output
values are green, and register names are red.
For this first trial we clear both the Output Area and Input Area by tapping the Clear
button two times. (Before the Input Area is cleared a permission box pops up.)
Now with the pen and enter: 3*4-7/3 then press
Compute.
The value 9.667 will appear in the output box. An "ordinary"
calculator would have displayed 1.666... because it would use a left to right calculation rather
than computing 3*4 then 7/3 and then subtracting as we understand algebraic formulas.
Now on the second input line enter: a=2; sr(a); a^2 then press
Compute. The output box now displays 4 lines: 9.667 9.667
1.412 4.00
Press the Compute and Clear buttons several times to see what happens.
Next press the Reg button. You will see that the A
register now has 2.00 and R has 4.00. That is because you stored 2 in A, and
R is the result register which contains the last computed
value 4.00.
Using the pen select register G, enter
20 and press Done. Now G contains 20. Press Reg again. This returns FormulaCalc to the Input/Output
areas. On the third input line enter G to the end of your routine.
Your routine should now read:
- 3*4-7/3
- a=2; sr(a); a^2
- g
Press Compute. You will see 20.00 added to your output lines, and
if you check the resisters (Reg) R will be
20.00 since it is now the last result.
You are now an expert!
To prove that, see if you understand the example on the right.
A better formatted answer version of this is shown below.
Note: To edit input in the Input Area you can hold down the pen to pop-up a
Copy/Cut/Paste action box.
Allowable Formula Objects
The allowable operators, functions and symbols are:
| arithmetic: | + - * / ^ %;
|
| functions: | sr() sq() ln() log() abs() int() pi deg rad
|
| trig: | sin() cos() tan() asin() acos() atan()
|
| assignment: | = += -= *= /=
|
| decision: | < <= = = >= >
|
| grouping: | ( )
|
| control: | ; if(,,) cc: dd: ds: se: sr:
|
| string: | " " st() [ ]
|
| comment: | [ ] #
|
The definitions for these are given below, but it is now time for you to try FormulaCalc for
yourself.
When you get puzzled or you want to save a routine for future use, come back. It's all explained
below.
This is the end of Quick Start.
Back to Document Section Links
Using FormulaCalc
Menu Actions
- View File -- will pop up a window showing the open routine.
- File to Pen -- will copy the open routine to the Input Area (Pen Area).
- Export Pen -- will copy the routine in the Input Area to the end of the
open Formula File. It will be titled #Exported Routine.
- Import Reg -- restore the Registers to that previously exported. This brings up a
'File Chooser' for selection of the desired exported register file.
- Export Reg -- saves the current Registers to a file. This brings up a 'File Chooser'
for naming a file and saving the contents of the Registers to that file. The saved file is
in the .CSV format so it is suggested that the extension be .CSV, but may be any desired
file type (extension).
- Debug On -- this overrides a sr:n setting to cause the assignments to
registers to be displayed. This actually toggles the override of sr:n off and on.
- Clear Regs -- this clears all registers to 0.
- GetNewFile -- this forces Open to display the 'File Chooser' so that
a new Formula File can be selected.
- About This is the usual About information. It tells you the version of
FormulaCalc you have installed.
- Quit The obvious Quit selection. You can also quit using the upper right
hand X. In either case you will asked if you with to save the current settings (i.e. Input
Area and Registers) of FormulaCalc for next usage start-up.
- Functions -- this pops up a window to allow you to copy a function to the end of the
Input Area. This pop-up window is shown at the right.
Back to Document Section Links
Storing Routines
You can store as many routines as desired in a Formula File(s). Also, there can be as many formula
files as desired. By convention formula files are given the file extension of .fmc, but may be
any desired file type (extension).
A Formula File has the following format:
- Each routine starts with a '#' sign in column 1 followed by the name. E.G. #Compound
Interest.
- A routine is of the form: formula followed by ; (and/or new line) followed by
formula .....
The routine is terminated by one or more blank lines.
All space characters within a formula are ignored.
Following is an example Formula File with two routines:
#Compound Interest
[Reg: I interest, P principle]
[N years, M periods per year]
dd:2
(1+i/m)^(m*n)*p
#Future Annuity
dd:2; ((1+i/m)^(m*n)-1)/(i/m)*p
This starts the name of the routine is Compound Interest.
Next is a 2 line non-printing comment as a reminder of the register contents.
dd:2 tells FormulaCalc to show 2 decimal digits in the output.
The formula (1+i/m)^(m*n)*p follows.
The second routine in the Formula File is Future Annunity.
As many routines as
desired may be in a Formula File. Each routine must start with a '#' in column 1.
See Programmed Input for control over the register values.
It is recommended that you create a Formula File, even if it is empty, in the directory with
FormulaCalc.ewe.
Having such a file allows you to check out routines written in the Input Area with the pen and
then export them with Menu/Export Pen when you have them working to your satisfaction.
Warning:
- Be sure to you choose the Formula File using Open even if there is nothing to open
before you try to export the Input Area. As mentioned above exported routines are given a
default name of #Exported Routine. Later you can edit the Formula File to give each a
correct unique name.
- If you open a Formula File which has more than routine named '#Exported Routine' only the
first such routine in a Formula File will be opened. Any other such routines will be ignored
until you give them a unique name(s).
Back to Document Section Links
Operators and Functions
This explains each of the operators and function.
The operators:
arithmetic:
- +
- addition -- e.g. 4 + 8 result: [12]
- -
- negation -- e.g. -4 or subtraction e.g. 5 - 2.02 [2.98]
- *
- multiplication -- e.g. 12 * 6 [72], 121 * -7 [-847]
- /
- division -- e.g. 36 / 4.321 [8.3314]
- ^
- x to power y -- e.g. 2 ^ 3 [8]
- %
- remainder of x divided by y -- e.g. 30.25 % 5 [0.05],
30.25 % 1 [0.25] the fractional part
The functions:
arithmetic:
- sr()
- square root -- e.g. sr(2) [1.1414]
- sq()
- square -- e.g. sq(2) [4]
- ln()
- natural logarithm -- e.g. ln(3) [1.0986]
- log()
- base 10 logarithm -- e.g. log(1000) [3]
- abs()
- absolute value -- e.g. abs(-654) [654]
- int()
- integer part -- e.g. int(30.25) [30]
- pi
- constant pi -- e.g. pi * 2 [6.283185307]
- deg
- constant 180/pi -- e.g. deg [57.29577951]
- rad
- constant pi/180 -- e.g. rad [0.017453292]
trigonometric:
- sin()
- sine -- e.g. sin(1) [0.8415]
- cos()
- cosine -- e.g. cos(1) [0.5403]
- tan()
- tangent -- e.g. tan(1) [1.5574]
- asin()
- arcsine -- e.g. asin(1) [1.5708]
- acos()
- arccosine -- e.g. acos(1) [0.0000]
- atan()
- arctangent -- e.g. atan(1.5574) [1.0]
assignment:
- =
- register store -- e.g. a = 2 [2] -- a cumulative example
- +=
- add and store -- e.g. a += 13 [15]
- -=
- subtract and store -- e.g. a -= 9 [6]
- *=
- multiple and store -- e.g. a *= 3 [18]
- /=
- divide and store -- e.g. a /= 3 [6]
decision -- used in if(,,):
- <
- less than -- e.g. a < 10
- <=
- less or equal -- e.g. a <= q
- ==
- equal -- e.g. 20 == w
- >=
- greater or equal -- e.g. t >= s
- >
- greater than -- e.g. d / 3 > 10 * 7 + a
The miscellaneous statements:
string:
- " "
- string -- e.g. "answer is:" [answer is:]
- st()
- convert number to string -- e.g. st(654) [654]
comment:
- #
- non-printing comment to end of line -- e.g. sin(30); # this is the angle
[0.500]
- [ ]
- non-printing comment -- e.g. [debug line] [ ]
- programmed input -- e.g. [@t,Temperature] [Opens a dialog box]
See Programmed Input
control:
- if(,,)
- select -- e.g. a=18; if (a<10, a, a/3)
[6] or a=9 [9]
- dd:
- decimal digits (0-15) -- e.g. dd:4; 1234.5; [1234.500]
- ds:
- display string
- ds:s; display string start
- ds:e; display string end
- e.g. ds:s; "The answer is: "; st(2^4); ds:e [The answer is: 16]
See Output Format Control
- se:
- exponent to display scientific notation (0-15) -- e.g. se:4 [ ]
- sr:
- show register assignments (y or n) -- e.g. sr:y [ ]
- cc:
- compution control
- cc:d trig formulas use degree cc:d -- e.g. cc:d; sin(2) [0.034899]
- cc:r trig use radians -- e.g. cc:r; sin(2) [0.909297]
- cc:t scientific notation trim trailing zeros -- e.g. dd:6; se:2; cc:t; 1234; [1.234e3]
- cc:z scientific notation show trailing zeros -- e.g. dd:6; se:2; cc:z; 1234; [1.234000e3]
Notes: The se: value determines at what exponent value the notation is
switched between fixed to scientific notation.
The cc:t or cc:z determines if trailing 0's in scientific notation are displayed.
More examples:
- When dd:2; se:5; 12345.6789 will display as 12345.68, but 123456.789 will display as 1.23e5
- When dd:2; cc:t; 10000.001 will display as 10000.00, but 100000.001 will display as 1e5
- When dd:2; cc:z; 100000.001 will display as 1.00e5
Back to Document Section Links
Default Control Settings
The default control values are:
- Degrees/Radians -- cc:d - Degrees
- Decimal digits -- dd:4 - 4
- Display scientific notation -- se:5 - when exponent e±5 or more
- Show register values -- sr:n - No
- Display trailing zeros -- cc:t - No (perform Trim)
Back to Document Section Links
Output Format Control
All numerical computation results are displayed on a single line in the Output Area, except
strings. Text and numerical values can be combined by using text strings and numerical strings.
Text strings are enclosed in " "'s. Numerical values are converted to strings by the st()
function. The control ds:s starts a concatenation of strings, and ds:e ends a concatenation
causing it to be displayed.
Strings cannot be assigned to a letter.
Instead writing the poorly formatted routine for converting Celsius to Fahrenheit and vise
versa, write the routine as follow:
[F to C and C to F. Input w]
dd:1;
ds:s; st(w);" F is "; st((w-32)*5/9); " C" ds:e;
ds:s; st(w);" C is "; st(w*9/5+32); " F"; ds:e
Check it out.
Note: Numeric values not converted to a string by st() are displayed immediately,
i.e. not delayed until the ds:e. Consider:
ds:s; w=10; st(w); " F is "; st((w-32)*5/9); " C"; ds:e -- Displays: 10.0000 F is -12.2222 C, but
ds:s; w=10; w; " F is "; (w-32)*5/9; " C"; ds:e -- Displays: 10.0000-12.2222 F is C
Programmed Input
The input values for the routines come from the registers. Typically values are placed in
registers before the computation is started.
However a routine can request that the user input values to be stored in registers.
This is done with the programmed input comment statement.
To request the user to input a register value, place the follow construct(s) at the end of a
line. It has the following line. The general construct is that of a non-printing comment []:
'[@' register letter, prompt ']', for example:
[@w,Temperature].
A dialog box will open to allow the user to enter a value. The current value of the register
will be displayed and highlighted.
The above routine for converting Celsius to Fahrenheit is shown next with a programmed input
command.
[F to C and C to F. Input w]
[@w,Temperature]
dd:1; ds:s
st(w);" F is "; st((w-32)*5/9); " C"
ds:e; ds:s
st(w);" C is "; st(w*9/5+32); " F"
ds:e
Note: Programmed input comment statement discussion:
Operator Calculation Order
This section discusses the order in which operators are used for a calculation when not
controlled by parenthesis.
The computation is done in a left to right order for the operators and functions of a given
group as listed next listed next. This means that operators in a given group are computed
in turn left to right and then the results of each group computation combined as specified
by the order. Parenthesis modify the order forcing computation to be completed within the
'( )' before combining with other values. See the example which follow the table.
Group computation order:
| First: | sr() sq() ln() log() int() pi
sin() cos() tan() asin() acos() atan() if(,,) deg rad
< <= = = >= >
|
| Second: | * / ^ %;
|
| Third: | + -
|
| Last: | = += -= *= /=
|
| Not Combined: | dd: sr: se: cc: " " [ ] ds:
st()
|
Example:
a = 10; deg Left to right
b = 2 * 3 + 5 * sin(a + 30) ^ 2 - 9 * (5 + 7)
| | | | \ / | | \ /
| | | | 40 / | 12 Compute inside ()'s 1st
| | | \ / / | |
| | | 0.64 / | | Then things in First
\ / \ / / \ /
6 3.21 / 108 Then Second (leftmost)
\ \ / /
\ 10.33 / And Second Again
\ / /
16.33 / Then Third (leftmost)
\ /
-91.67 And Third Again
Finally the assignment
Back to Document Section Links
Examples
This section explains three examples in detail. The Julian Calendar is quite complicated but it
is a good example of register storage, the if(,,) statement and number encoding.
Example 1:
This example shows the use of arithmetic assignments to registers, and iteration.
#Powers of 2 Routine title
sr:y Show register store assignments
u += 1; v *= 2
This routine sets the output display to show register assignments. Then 1 is added to the current
value of u and re-stored in u, and
the current value of v is multiplied by 2 and re-stored in v.
Assume the initial value of the register u is 0, and v is 1.
Pressing Compute produces output of: 1 2 because 1 was added to
u and v was multiplied by 2.
Pressing Compute again produces: 2 4 and again 3
8 etc.
Powers of 2 -- 1 raised to 2 is 2, 2 raised to 2 is 4, 3 raised to 2 is
8, etc.
Example 2:
This example shows the use of the int() function (i.e. whole number extraction).
Julian Date was defined by astronomers to have a uniform date code independent of the calendar. It makes
taking the difference between 2 dates easy. (See note below.)
#Julian Date
sr:n; dd:2; se:10
i=int(z/100); i=2-i+int(i/4)
int(365.25*z)+int(30.6001*(x+1))+y+1720994.5+i
Assume that register x (month) is 10, y (day) is 15, z
(year) is 1999 (October 15, 1999).
This routine sets the output display to not show register assignments; to display 2 decimal
digits; don't display scientific notation for numbers <= 10 digits.
It then divides the year by 100, and fills the whole number part into register i. i is then further manipulated for leap
years. The result is the integer part of a year and a month calculation, all added to the day, a
constant and i.
The result displayed is: 2451466.50
It would be a good exercise to see the results of all computations by overriding sr:n.
You do this by accessing Menu/Debug On
The output is then: 19 -17 2451466.50
Note: A Julian Date is defined to start at noon and show the fraction of a day. So to be
accurate the day in y should be a day and a fraction. If
y was 15.5 then noon on October 15, 1999 is the start of Julian Day
2451467.00
This routine is only accurate for the Oregonian calendar. A modification of this routine must be
made for dates before October 15, 1582.
Example 3:
This example is really too complicated but it shows the use of the if(,,) function, and it
shows how to encode 3 numbers into 1. It produces the calendar date for an Julian
date, and show the fraction of a day to two decimal places.
#Julian Calendar Routine Title -- a comment
dd:6; se:10; sr:n 6 decimal digits, scientific notation if exponent >= 10, no register values
i=int((z+1-1867216.25)/36524.25); number of centuries
i=z+1+i-int(i/4);i=i+1524; leap days
j=int((i-122.1)/365.25) a year value
m=int(365.25*j); k=int((i-m)/30.6001)
i=i-m-int(30.60001*k) day of the month
m=if(k<13.5,k-1,k-13); month number
if(m>2.5,j-4716,j-4715)+(m+i/100)/100 answer dependent on month value
The last line computes the year depending on the month. If the month is greater than
February then the year is j-4716 otherwise it is j-4715. Add to the year a fraction of the
combined month, day and fraction of a day. The form mmdddd. So the answer is yyyy.mmdddd
(where dddd means: day dd -- implied decimal point -- decimal part of the day dd). In
general, this scheme is a good way to display 3 different numbers as one number.
To see the result put 2451467.00 in register z. Pressing Compute produces: 1999.101500. That is, noon on
October 15, 1999.
Back to Document Section Links
Contact Info
FormulaCalc was created by
David W. Bray, Potsdam, NY;
Copyright © 1999-2005 David W. Bray, All Rights Reserved.
The Bray Palm OS Page can be found at:
http://davidbray.org/palm/
Registering
FormulaCalc is freeware no registration is required. We hope you enjoy using it.
I would appreciate receiving e-mail about what computer(s) you are using FormulaCalc on, and any
other feedback and suggestions you would like to share with me.
This archive may be freely redistributed, provided it is made available only in its
complete, unmodified form with no additional files and for noncommercial purposes only.
Any other use must have prior written authorization from
David W. Bray.
Unauthorized commercial use includes, but is not limited to:
- FormulaCalc itself as a product for sale.
- Accompanying a product for sale.
- Accompanying a magazine, book or other publication for sale.
- Distribution with 'Media', 'Copying' or other incidental costs.
- Available for download with access or download fees.
Disclaimer
This program is provided without warranty and the user accepts full responsibility for
any damages, consequential or otherwise, resulting from its use.
Foot Notes
¹ Ewe is developed by Michael L Brereton. We are indebted to him for his outstanding
software product and making it freely available. Thank you Michael!
Program Changes in Version 1.1
FormulaCalc for Ewe Version 1.1 Bld:511 differs from Version 1.0 Bld:438 in:
- Added programmed input (V1.1 Bld:511)
- Added horizontal scroll bar in the Input Area (V1.1 Bld:511)
Bld:511 is the current release.
To be sure that your version is up-to-date check the Bld: number in the current description of
Riseset at: http://davidbray.org/mobile/