home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Lion Share
/
lionsharecd.iso
/
dos_misc
/
qcalc113.zip
/
QCALC.DOC
< prev
next >
Wrap
Text File
|
1991-10-30
|
50KB
|
1,635 lines
╒═════════════════════════════════════════╕
│ ╓──╖ ╓──╖ ╓──╖ ╖ ╓──╖ │
│ ║ ║ ║ ║──╢ ║ ║ Version 1.22 │
│ ║ ╖║ ║ ║ ║ ║ ║ ─══════════─ │
│ ╙─╫╜ ╙──╜ ╙ ╜ ╙─╜ ╙──╜ │
│ ╙ The Quick Calculator │
╘═════════════════════════════════════════╛
Copyright (c) 1991
John Newlin
66 Birchwood Drive
Millington, NJ 07946
"I just did it because I hate the system so much." - Dave
QUICK INTRODUCTION
------------------
There you are by your computer, your friends are watching, and
you're doing your gosh darndest to impress them. You go through
all your games, show off your Sound Blaster, bring up the Sports
Illustrated Swimsuit Issue in Super VGA, and to top it off, you
call up Compuserve and download a program you don't even want
just to show you could do it. And then some guy in the back asks
you for the square root of two. How embarrassing. Well, you
could load up GWbasic and putz around there, or wait for Lotus to
load and take a couple minutes dropping numbers in cells. But
you know, what would really impress this guy the most is if you
could give him the answer quickly.
"Were trapped! Like rats!" - T.J.
WHAT IS QCALC?
--------------
QCALC is a command-line calculator. That is, all the information
you will ever need to give it, you can type on the command line,
right after the program name. It handles numbers with 15 digit
precision, and can print the answer nearly any way you want. You
can calculate several expressions all at once, on the same
command line. You can assign the answer of an expression to a
variable, and reuse that variable in the expressions that follow
on the command line. QCALC has several variables (constants)
predefined for your use, as well as over 60 trigonometric,
financial, conditional, and logical functions to aid in your
calculations.
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 2
"I think I live in the fourth dimension." - Sam
HOW TO USE QCALC
----------------
Four things (arguments-types) may be found on a command line.
These four things may occur in any order. A space must be
between each argument. The argument types are:
Expressions: An expression is what it's all about; A
mathematical "formula" for QCALC to solve. An expression may be
assigned to a variable, in which case the expression will begin
with a variable name, and a colon. 5*5 is an expression.
log(5/pi)^2 is also an expression. my_var:1.6%.45 is an
expression being assigned to a variable.
Switches: Any parameter starting with a forward slash (/).
Switches modify the default usage of QCALC, affecting such
elements as precision, variables, and the specifics of output.
/f is a switch. /oo is also a switch. /oof are two switches,
combined into one argument.
Script Expansion: Any parameter starting with an at sign (@) and
followed by a filename (with or without a path). The file named
will be read by QCALC, and any data contained in that file will
be added to the command line. @bob is a script expansion of the
file "bob". @c:\ted.qc is another script expansion.
Input Prompting: And parameter beginnging with an exclamation
mark (!) and followed by a variable name, pre-existing or yet-
undefined. QCALC will prompt the user for the contents of the
variable before continuing. !frank prompts for an expression,
this expression is placed in variable "frank".
!I_am_10_years_old is another prompt instruction.
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 3
"I was trying to astrally project, but I got it wrong." - Bill
A CLOSE LOOK AT EXPRESSIONS
---------------------------
QCALC understands six basic operator types, plus some more
advanced operators. The following shows six different
expressions, each employing a different operator:
QCALC /oo 6+3 6-3 6*3 6/3 6%3 6^3
Ignore the /oo at this time, it's purpose is to clean up the
output. The result you will see is:
9 3 18 2 0 216
Expressions can be parenthesis nested; you can have any amount of
parentheses in the expression. For example, this example
retrieves the square root of 25 (which is 5), adds 1 to it
(making 6), and divides the result by 2 (the final answer is 3).
QCALC (sqr((2.5*2)*5)+1)/2
And QCALC responds ...
QCALC -> (SQR((2.5*2)*5)+1)/2 = 3
All these parentheses may not be necessary, however. Certain
operators have a higher precedence than others. Take a look see
at the operator descriptions that follow.
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 4
"She's my woman, she's my woman,
she's my sweet hot dog woman." - Ben
OPERATORS AND PRECEDENCE
------------------------
Parenthesis have the highest precendence. They are evaluated
before anything else. Parentheses may be nested for an unlimited
length (or until the stack runs out, which makes a LARGE
expression).
The exponent operator (^) has the next highest precedence. This
operator brings the left value to the power of the right value.
It is the operator equivalent of the function POW(x,y).
Multiplication (*), division (/) and modulus (%) have equal
precedence. This means that whichever of the three come first in
the expression (left to right) is evaluated first. Modulus, by
the way, computes the remainder of a division expression. (5%2
is 1, since 5/2 leaves a remainder of 1.)
Addition (+) and subtraction (-) have equal precedence. (Note
that the "negative sign" (-), found next to a negative number, is
not the same as the subtraction operator. Sign negation takes
precedence over all operators below parentheses.)
Greater than (> or }), less than (< or {), equal to (=), greater
than or equal to (>= or }=), and less than or equal to (<= or {=)
are all logical operators with equal precedence, each resulting
with a 1 or a 0. (True is 1, 0 is false.) These operators
emulate the functions, respectively, GT(x,y), LT(x,y), EQ(x,y),
GOE(x,y), and LOE(x,y). Note that the angle brackets (> and <)
are equivalent to the curly braces ({ and }). Due to DOS's
inability to handle angle brackets, always use curly braces on
the command line. They work fine, however, in script files.
Also note that you will most likely not be able to use angle
brackets, or the equal sign, in the QCALC environment variable,
as the SET command does not like them. There is no operator
equivalent to the = sign, however. Use the EQ(x,y) function in
the environment variable.
Of least precedence are logical AND (&) and logical OR (| or $),
equivalent to functions AND(x,y) and OR(x,y). DOS can't handle
the | on the command line or in an environment variable, so the
equivalent operator $ has been provided. You may use | in script
files, however.
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 5
"This is so disgusting." - Dave
VARIABLES
---------
To use a variable in an expression, just substitute the number
with the name. For example, pi is predefined as 3.14...etc. The
following multiplies pi by 5:
QCALC pi*5
To define a new variable, tack on a variable name and a colon
just before the expression. This example declares a variable
named "radius", stores 5 in it, and multiplies it by pi. It is
identical to pi*5 above.
QCALC radius:5 pi*radius
QCALC allows great flexibility in how you assign a number to a
variable. The following assigns the number 50 to variable
"fifty":
QCALC fifty:10*((2*2)+1)
User defined variables are not constants; they can be assigned
new values later on the command line. Internal (pre-defined)
constants, however, may not be changed.
Let's say you have an expression you would like to repeat, but
with different values each time. You can tell DOS to prompt you
for the value of a variable by creating it with an exclamation
mark:
QCALC !days hours:24 days*hours
When executed, QCALC will first ask you for the value of DAYS.
After you enter it, it will finish evaluating the expressions.
Hit F3 (ENTER) to run QCALC again and enter a new value for DAYS.
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 6
"Cockroach!!!" - A guy with a huge wrench,
a crazy person with a plunger,
and a madman with isopropyl and a lighter.
PRINT OPTIONS
-------------
QCALC can print results in many different ways. Consider the
following command:
QCALC /or abs(-10) /% .1 /%f 150.25*278.55
And QCALC prints ...
10
10%
$41,852.13
The switch /OR turns on "result only". In actuality, /OR is just
a shortcut switch. It does the same work as if you had turned on
switches OQ, OX, and OE (see section SWITCHES). The function abs
converts -10 to a positive number, so it prints 10. /% puts
QCALC into percentage mode. .1 is ten percent in this mode, so
QCALC prints 10%. /%f is two switches combined into one
parameter. /% tells QCALC to turn percentage mode back OFF, and
/f to turn financial mode ON. This mode prints a dollar sign,
then the result of the expression with commas every third digit.
The number is also brought to two decimal places.
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 7
"What, you're going to tell me Ringo was talented?" - Rene
ANYTHING I SHOULD KNOW?
-----------------------
-*-
An expression should never have a space anywhere in it. This
will confuse QCALC into thinking the space is where the
expression ends. Only use spaces to separate switches and
expressions from each other.
-*-
To save the results of QCALC into a file, use DOS redirection.
At the end of the command line, append > filename.ext, where
filename.ext is the file where you want to save the answers.
Example: QCALC sin(.9) > myfile.txt
-*-
I highly recommend using DOSKEY (bundled with MS-DOS 5.0) or 4DOS
(available through shareware) with QCALC. The command line
editing capabilities of these utilities make QCALC much simpler
to use. However, for those who don't use DOSKEY or 4DOS, an
"editor" switch will be implemented in future versions.
-*-
Variable names can consist of letters of the alphabet, digits,
and the underscore (_) character. They may be of any length, but
they must not begin with a digit.
-*-
Occasionally, you'll do something that will cause QCALC to barf
out an error. Check the section on ERRORS for a full list. Note
that a caret (^) attempts to point out the error. Use the /E
switch to modify the appearance of errors.
-*-
If there are some switches you frequently turn on, and some
variables you frequently use, you can place them in a DOS
environment variable. When QCALC is executed, it first checks
the environment variable "QCALC" and evaluates any arguments you
have there. The following creates an environment variable ...
SET QCALC=/op weeks_in_month:4 months_in_year:12 /nf
... To remove an environment variable, type SET QCALC= but do not
supply any data. This particular setting creates two variables
silently (/OP), restores the default settings (/N), and turns on
financial mode (/F).
Do not put the switches /I, /H (or /? or ?), or /L in the QCALC
variable. /FNORD can be placed there, however. Do not put
either of the angle brackets (< or >) or the equal sign (=) in an
environment variable (the SET command barfs on it). Use the
equivalents: { for <, } for >, and EQ(x,y) for x=y.
-*-
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 8
You can store many switches and expressions (and variable
definitions) in a script file, and read in that file by use of
the script file expansion (@) operator. The file may contain any
number of switches and expressions, and each can be separated by
a space or a carraige return. Blank lines are ignored. Since
QCALC evaluates each argument from left to right, the contents of
the script file are not evaluated until @filename is found. Any
expressions before the @filename argument may not make use of any
variables created inside the script file. The default extension
is ".QC," and if the file cannot be found in the current
directory, QCALC searches the directory where QCALC.EXE resides.
The file "c:\stuff\bob.qc" contains a variable named "bob". The
following loads in bob, and multiplies it by five ...
QCALC @C:\STUFF\BOB.QC BOB*5
Script files can contain some special characters:
A semicolon (;) is a comment. Everything from the semicolon
until the end of the line is ignored.
A pound sign (#) print everything from the pound sign to the end
of the line to the screen. Do not place a semicolon on the same
line as a pound sign. (Er, well, you can, but you may not get
what you expect.)
A tilde (~) tells QCALC to pause. QCALC pauses until the user
hits a key, or aborts the script by hitting the ESCAPE key.
The input-variable character (!) can be used in script files to
make them more interactive and reusable. Script files will be
greatly expanded upon in future versions, but do not count on
backward compatibility. Note that there are only two things you
CAN'T do in a script file; you can't use /FNORD, and you can't
include another script with the @filename argument.
-*-
If you like a "running-tape" calculator, and have a printer, use
CONTROL-PRINTSCREEN. This tells DOS to turn on "line printing".
When you are done printing, hit CTRL-PS again to turn off the
printer.
-*-
The functions QCALC employs are not heavily tested at this point,
so use them with care. If a function seems accurate, it probably
is, but remember they come from a variety of sources. About 25
are from Borland C++'s math library, about another 24 I wrote
myself, and they make calls to Borland's functions, and another
11 are from Howard Kapustein's Turbo C library (TCHK 2.0).
-*-
I've just thought of a use for the /OA switch. If you type an
expression on the command line, and then realize you would like
to have this expression in a script file, insert the switches
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 9
/FNORDOPOQOEOA to before the expression, append "> script.qc" to
the end of the command line, and re-execute the line. This will
have the effect of printing just the expression (variables are
ignored: /OP) and saving the expression in the file "script.qc".
/OA turns OFF answer printing to make this possible. Great, eh?
Okay, a bit of a pain, but it's now I can say QCALC features
"auto-scripting". Heh heh.
-*-
Simulated functions: If you wish to multiply two values, you use
the * operator as in 5*6. However, if the second value is
surrounded by parentheses, multiplication is assumed if no
operator exists as in 5(6). Using this technique, you can create
variables that appear to work as functions. For example:
QCALC one_tenth:.1 one_tenth(5)
This reports .5 as the answer, which is one-tenth of 5. All it
is doing, though, is multiplying one_tenth (.1) by the amount in
the parentheses. The constant "rad" can appear to work as the
function "torad":
QCALC torad(90) rad(90)
These two answers will be identical. However, do realize that a
simulated function does not report errors as a real function does
-- don't forget that it IS a variable.
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 10
"I don't think so." - Angeler
REGISTRATION, OTHER BORING TOPICS
---------------------------------
Read the file REGISTER.TXT for full information on registering
this version of QCALC. Trust me, it's cheap. And if you don't
use it often, I'm not asking you to delete your copy. Use it.
If it ever becomes handy enough to justify the cost, register.
This applies only to home use, however. Please do not install an
unregistered copy of QCALC on a business machine for anything
other than a test drive. Registration is mandatory for business
use.
I wrote a story about an old folks home that gets a shipment of
bum radioactive peas and all the senile old people get mutant
powers. The teacher didn't like it, however. I thought it was
pretty funny, but he said the main character wasn't likeable.
You're not likeable, I said. No, actually I didn't, but I should
have... Oh, I'm sorry, am I boring you?
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 11
"You ever wonder?" - Mike
A WORD ABOUT CONSTANTS AND FUNCTIONS
------------------------------------
Any functions that take an angle as a parameter work only in
radians. To convert degrees to radians, use the function torad,
or multiply degrees by rad (pi/180). Remember, do NOT put a
space between the function name and the parentheses, nor a space
after the numbers or commas. Or anywhere else in an expression
for that matter.
Any number that is nonzero is "TRUE". Any number that is zero is
"FALSE". This does NOT apply to functions that require a value.
For example, if variable barf equals 5, the expression EQ(barf,5)
would return 1 (TRUE): However, the expression EQ(barf,TRUE)
would not return TRUE. EQ compares values, not logic. For
logical equality, use AND. AND(barf,TRUE) will return TRUE.
Note that some functions have operator equivalents that may or
may not be desirable. (In the above example, AND is operator &
and EQ is operator =.)
Constants may not be changed -- that's why they're called
constants. Don't let that stop you from changing your own user-
defined variables, though.
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 12
"That's an awful lot of garbage." - Jason
LIST OF CONSTANTS
-----------------
PI
The ratio of circumference to diameter. Defined as
3.14159265358979323846.
E
The base of natural logarithms. Defined as
2.71828182845904523536.
RAD
Converts degrees to radians. If x is in degrees, multiply x by
rad and you will have x radians. Defined as pi/180.
DEG
Converts radians to degrees. If y is in radians, multiply y by
deg and you will have y in degrees. Defined as 1/RAD. However,
an alternate (and more accurate) approach is to divide y by RAD.
TRUE
Logical true. Defined as 1, however any number that is nonzero
is "true".
FALSE
Logical false. Defined as 0.
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 13
"Oh, man! Oh, man." - Sam
LIST OF FUNCTIONS
-----------------
SIN(X)
Sine.
COS(X)
Cosine.
TAN(X)
Tangent. sin(x)/cos(x).
SEC(X)
Secant. 1/cos(x).
COSEC(X)
Cosecant. 1/sin(x).
COTAN(X)
Cotangent. 1/tan(x).
ASIN(X)
Inverse (arc) sine. x must be between -1 and 1.
ACOS(X)
Inverse (arc) cosine. x must be between -1 and 1.
ATAN(X)
Inverse (arc) tangent.
ASEC(X)
Inverse (arc) secant.
ACOSEC(X)
Inverse (arc) cosecant.
ACOTAN(X)
Inverse (arc) cotangent.
SINH(X)
Hyperbolic sine.
COSH(X)
Hyperbolic cosine.
TANH(X)
Hyperbolic tangent.
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 14
SECH(X)
Hyperbolic secant.
COSECH(X)
Hyperbolic cosecant.
COTANH(X)
Hyperbolic cotangent.
ASINH(X)
Inverse (arc) hyperbolic sine.
ACOSH(X)
Inverse (arc) hyperbolic cosine.
ATANH(X)
Inverse (arc) hyperbolic tangent.
ASECH(X)
Inverse (arc) hyperbolic secant.
ACOSECH(X)
Inverse (arc) hyperbolic cosecant.
ACOTANH(X)
Inverse (arc) hyperbolic cotangent.
LOG(X)
Natural logarithm. x must be greater than 0.
LOG10(X)
Natural logarithm, base 10. x must be greater than 0.
POW(x,y)
Exponentation function x to the power of y. Equivalent to
operator expression x^y.
EXP(X)
Exponential function e to the xth power.
HYPOT(X,X)
Hypotenuse of a right triangle.
TORAD(X)
Converts x from degrees to radians. (See rad.)
TODEG(X)
Converts x from radians to degrees. (See deg.)
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 15
SIGN(X)
The sign of x. If x is positive, sign returns 1. If x is
negative, sign returns -1. If x is zero, sign returns 0.
SQR(X)
Square root of x. x must not be negative.
RND(X)
Random integer from 1 to x. x must be between 1 and 65535.
ABS(X)
Absolute value of x. Converts x to a positive number.
MIN(X,Y)
Returns whichever is smaller. Identical to IF(LT(x,y),x,y).
MAX(X,Y)
Returns whichever is larger. Identical to IF(GT(x,y)x,y).
SLN(Cost,Salvage,Life)
Straight Line depreciation.
SYD(Cost,Salvage,Life,Period)
Sum Year Digits depreciation.
DDB(Cost,Life,Period)
Double Declining Balance depreciation.
ASLN(Cost,Salvage,Life)
Accumulated Straight Line depreciation.
ASYD(Cost,Salvage,Life,Period)
Accumulated Sum Year Digits depreciation.
ADDB(Cost,Life,Period)
Accumulated Double Declining Balance depreciation.
PMT(Principal,Interest,Term)
Periodic payment required to fully amortize a principal.
FV(Payment,Interest,Periods)
Future Value of a single amount.
FVA(Payment,Interest,Periods)
Future Value of a annuity.
PV(Payment,Interest,Periods)
Present Value of a single amount.
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 16
PVA(Payment,Interest,Periods)
Present Value of an annuity.
AND(x,y)
Logical And. Returns TRUE if both x and y are both TRUE.
Otherwise, it returns FALSE. Identical to the operator
expression x&y.
OR(x,y)
Logical Inclusive Or. Returns TRUE if either x or y are TRUE.
Only returns FALSE if x and y are both FALSE. Identical to the
operator expressions x|y and x$y.
XOR(x,y)
Logical Exclusive Or. Returns TRUE if either x or y is TRUE, but
not both. Only returns FALSE if both are TRUE, or both are
FALSE. XOR has no operator equivalent.
NEG(x)
Logical Negation. Returns TRUE if x is FALSE. Returns FALSE if
x is TRUE. Negate has no operator equivalent.
NOT(x)
Identical to NEG. See NEG.
IF(x,a,b)
Conditional Answer. If x is TRUE, the value of a is returned.
Otherwise, the value of b is returned.
EQ(x,y)
Equal To. Returns TRUE if x is equal to y. Otherwise returns
FALSE. Equivalent to operator expression x=y.
GT(x,y)
Greater Than. Returns TRUE if x is greater, but not equal, to y.
Otherwise returns FALSE. Equivalent to operator expressions x>y
and x}y.
LT(x,y)
Less Than. Returns TRUE if x is less than, but not equal, to y.
Otherwise returns FALSE. Equivalent to operator expressions x<y
and x{y.
GOE(x,y)
Greater Than Or Equal To. Returns TRUE if x is greater than or
equal to y. Otherwise returns FALSE. Identical to
OR(GT(x,y),EQ(x,y)). Equivalent to operator expressions x>=y,
and x}=y.
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 17
LOE(x,y)
Less Than Or Equal To. Returns TRUE if x is less than or equal
to y. Otherwise returns FALSE. Identical to
OR(LT(x,y),EQ(x,y)). Equivalent to operator expressions x<=y,
and x{=y.
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 18
"Rastafarians? Hey, I know Rastas, man." - Seth
LIST OF ERRORS
--------------
SYNTAX ERROR!
Any general bewilderment. Illegal characters can produce a
syntax error, but they will produce a bad operator error if the
expression is expecting an operator at that point. Using a
variable as a function, or vice versa, will create a syntax
error.
MISMATCHED PARENTHESES!
The expression does not have the same amount of left parenthesis
as it does right parenthesis, or QCALC encounters a right
parenthesis before it's matching left. Example: QCALC )(.
OVERFLOW ERROR!
Somewhere along the calculation of the expression, the number got
waaaay too big. An overflow error will also be caused by
"underflow" (a number got way too small).
DIVISION BY ZERO ERROR!
The right value of a divide or modulus expression is zero. You
cannot divide by zero, it's against the law. You can get
arrested. Example: 5/0 is illegal.
DOMAIN ERROR!
You have called a function but given illegal values to it. For
example, ASIN(x) requires x to be between -1 and 1. ASIN(10)
would produce a domain error. A domain error is also produced
when a function call causes a total loss of significant digits.
For example: sin(10e70).
UNKNOWN SYMBOL!
The symbol name pointed to does not exist as either a variable,
or a function. You haver either misspelled the symbol, or you
have a slight case of brain damage.
BAD OPERATOR!
Syntax error. The expression contains an illegal character, when
it's looking for an operator.
IMPROPER NUMBER OF PARAMETERS!
You have called a function, but have either supplied it with too
many parameters, or not enough. Look up the function with the /L
switch for number of parameters; QCALC /L.
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 19
CONTROL-C ENCOUNTERED! ABORT MISSION! ABORT MISSION!
You hit CONTROL-C or CONTROL-BREAK before QCALC finished
calculations. Jerk.
WARNING: NULL STATEMENT REACHED PREMATURELY!
I doubt you'll see this error. It's an old error detection
scheme used in the earliest versions of QCALC. However, if it
does occur, please notify the author (me) of the circumstances
under which it happened. Then hear me faint.
ALERT AUTHOR: BUG! RAID! BLACK FLAG! HELP!
This is a bug. This bug means death. It represents conditions
that I, in my small imagination, thought couldn't occur. If it
does occur, alert the author (me) and send him (me) a copy of the
command line you used that produced the error.
NO NAME GIVEN!
You began an expression with a colon. QCALC thinks you want to
assign the expression to a variable.
BAD VARIABLE DEFINITION!
A colon, which dilineates a variable from the expression, was
found in a location that made QCALC wonder who put you in charge.
EMPTY EXPRESSION!
You begin the expression with a variable name and an equal sign,
but that's it. QCALC can't define a new variable unless it has a
value to give it.
SYMBOL IS IN USE!
The expression is attempting to define a variable with a name
that is already in use. The name is being used by a function.
See the next error.
SYMBOL IS A CONSTANT!
The expression is attempting to define a variable with a name
that is already in use. The name is being used by a constant
(pre-defined internal variable). See the previous error.
ABNORMAL PROGRAM TERMINATION
This is a major error that QCALC has failed to trap. Again,
please send to the author (again, me) the description of the
error, and the full command line under which this error occurred.
FATAL: CAN'T LOAD xxx!
The script you are trying to expand with the @filename parameter
cannot be loaded for some reason. Either it doesn't exist, or
there is a disk error.
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 20
"Come on, John, let's get drunk." - Ben
A WORD ABOUT SWITCHES
---------------------
QCALC's switches are not case sensitive. Switches marked
(TOGGLE) in the following list can be turned on and off by
selecting the switch again. For example, /$ prints a dollar sign
before the number. The command ...
QCALC /$ 20 /$ 20
... prints two numbers. The first number will have a $ before
it, and the second will not, since the option was toggled off.
Several switches can be combined into one parameter. For
example, the /$ and /C switches can be turned on by /$C.
Switches marked (SINGLE) in the following list are information
switches -- they override and ignore all other switches to print
a message, give help, etc. For example, the command ...
QCALC 5*5 /?
... brings up the help screen. It does NOT print the result of
the expression 5*5, because /? is marked (SINGLE), and overrides
normal switches. (SINGLE) switches can be used anywhere on the
command line, but only the first (SINGLE) switch encountered will
be recognized -- all other arguments will be ignored. (Get it?)
Some switches take arguments. For example, /P is the precision
switch. It expects a number (NUM) after the switch (ie, /P10).
/E is the error switch. It expects a letter (LET) after the
switch (ie, /EV). If a switch requires a certain type argument,
and that type is not given, or no argument is given at all,
unexpected errors may occur. If in doubt of how a switch works,
do not combine it with another switch in the same parameter (ie
/P10$ combines /P and /$ together) -- combining switches
improperly can confuse QCALC and make it cuckoo.
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 21
"Ayep." - Ocean
LIST OF SWITCHES
----------------
SWITCH /I: Gives information on the current version of QCALC.
(SINGLE) Prints a short text description about this version of
QCALC, and information regarding registration (blah).
Usage: QCALC /I
SWITCH /L: Lists mathematical functions and constants.
(SINGLE) Prints a list of mathematical functions that QCALC
understands, and any predefined constants. Also lists legal
operators.
Usage: QCALC /L
SWITCH /H: Help screen.
(SINGLE) Shows QCALC's usage and available switches. The
following are equivalent usages of the /H switch:
QCALC /H
QCALC /?
QCALC ?
SWITCH /%: Prints number as a percentage.
(TOGGLE) Each number is converted to a percentage (multiplied by
100), and printed with a percent sign (%) after it.
Example: QCALC /% .65
Result: QCALC -> .65 = 65%
SWITCH /$: Puts a dollar sign before each number.
(TOGGLE) Each answer is printed after a dollar sign ($).
Example: QCALC /$ 5*5
Result: QCALC -> 5*5 = $25
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 22
SWITCH /C: Delineates each number with commas every third digit.
(TOGGLE) Prints numbers with commas.
Example: QCALC /C 1234
Result: QCALC -> 1234 = 1,234
SWITCH /P: Changes the precision.
(NUM) Requires an argument from 1 to 15. Final answers will be
rounded up or down to the specified precision.
Example: QCALC /P5 1234.56
Result: QCALC -> 1234.56 = 1234.6
SWITCH /D: Changes the number of places after the decimal point.
(NUMBER) Requires an argument from 0 to 15. /D15 is the default
amount of digits to be printed after the decimal point. /D0 will
always print numbers whole, and with no decimal point. Zero
padding is controlled by the "minimum digits" argument, as below.
Any fractional part of a number beyond the specified argument
will be truncated.
=OR=
(TOGGLE-LETTER) Requires the letter 'M' as an argument.
"Minimum digits" defaults to ON. When minimum digits is on, any
fractional part smaller than the specified digit limit will NOT
have trailing zeroes, and if there is no fractional part, a
decimal point will not be printed. With minimum digits off, all
numbers with a specified digit limit greater than zero WILL have
a decimal point, and will be zero padded up until the limit.
Example: QCALC /v a:123.123 /D2 a /D0 a /DMD4 a /DM 123.12345
Result: QCALC -> A = 123.12
QCALC -> A = 123
QCALC -> A = 123.1230
QCALC -> 123.12345 = 123.1234
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 23
SWITCH /F: Prints answers financially.
(SEMI-TOGGLE) Prints answers with a dollar sign, commas, and two
digits after the decimal point, trailing zeroes if necessary.
Financial mode is considered "ON" if ALL of the following
switches are set: /$CD2DM. If any of these settings are
changed, financial mode is toggled "OFF". If financial mode is
on and /F is called, the above settings are returned to their
default values.
Example: QCALC /F 12345.12345 500
Result: QCALC -> 12345.12435 = $12,345.12
QCALC -> 500 = $500.00
SWITCH /Ox: Alters the output of answers.
(LET/TOGGLE) Has a number of arguments. These are:
Q Toggles printing of "QCALC ->".
X Toggles printing of the expression.
E Toggles printing of the equal sign.
R Prints answers (results) only. Same as /OQOXOE.
A Toggles printing of the answer. (Got a use for this?)
V For variables, toggles printing of "[var NAME]".
N Toggles printing of the newline (carraige return).
S Toggles printing of the separator. (See /S.)
O Prints answers all on one line. Same as /OSONOR.
P Supends printing of variable creation. (All parts.)
D Restores all /O defaults.
Example: QCALC /OO 5*5 5+5 5-5
Result: 25 10 0
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 24
SWITCH /E: Alters the printing of errors.
(LET) Requires N B H or V as an argument. /EN prints NO errors.
If an error occurs, no mention will be made of the error. This
may result in "empty lines" -- be careful with this switch! /EB
prints BRIEF errors. If an error occurs, "Error!" is printed,
rather than the description of the error. /EH prints full errors
(same as /EV), but halts QCALC once an error occurs. (This may
be a desirable option to put in the QCALC variable.) /EV prints
VERBOSE errors. This is the default -- when an error occurs,
QCALC prints the full error message, and a caret (^) on the next
line attempts to point out the error. In the following example,
/EB turns BRIEF printing on. The symbol "sin" is not a variable,
it's a function, so QCALC reports "Syntax error!" However, since
/EB is on, it only reports ...
Example: QCALC /EB 5*sin
Result: QCALC -> 5*SIN = Error!
SWITCH /S: Changes the separator between answers used with /OS.
(STRING) REQUIRES a string as an argument. This string MUST be
surrounded by quotes. (Quotes are necessary because of the way
DOS parses strings -- screwy things may occur without them.) In
actuality, the S and the string do not have to be touching (there
can be a space between them) -- the S only signals that the next
argument is a string. But a string surrounded by quotes MUST be
the next argument. The separator is only active when the /OS
switch is turned on. The default separator is a single space --
this separator is printed between any answers. The following
turns on single line printing, and selects a space, two hyphens,
and another space as the separator. (To remove that third
separator, put a /OS before the 3 on the command line.)
Example: QCALC /OOS" -- " 1 2 3
Result: 1 -- 2 -- 3 --
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 25
SWITCH /N: Restores all switches to their defaults.
This switch is NOT a toggle switch. Once specified, answers will
be printed as if no switches were ever called (restored to their
default parameters). This includes any switches in the QCALC
environment variable! The following example turns on financial
printing and prints only the answers. Then it prints a number,
restores defaults, and prints the number again.
Example:
QCALC /FOR 1234.1234 /N 1234.1234
Results: $1,234.12
QCALC -> 1234.1234 = 1234.1234
SWITCH /FNORD: Suspends the printing of the opening header.
"Quick-Calculator Version blah blah blah" can be suspended by
having /FNORD as an argument anywhere in the command line, or in
the QCALC environment variable. /FNORD may be combined with
other switches, despite its unsightly appearance. /FNORD will
not have any affect inside of a script file.
The following prints NOTHING at all:
QCALC /FNORD
"I love beer." - Brent
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 26
THANKS AND REGRETS
------------------
Thanks to Scott Straley and Greg Matyola for advice and beta-
testing on this project.
Thanks to the people who make the software I use:
Borland, Inc. Borland C++
Semware Quick Edit 2.10
Howard Kapustein Turbo C library (TCHK 2.0)
Vern Buerg List 7.5i
Word Perfect, Co. Word Perfect 5.1
This is the first release of QCALC, so I imagine many bugs will
pop up and annoy people, and the lack of hindsight will come back
to haunt me. If you have any errors to report, or suggestions to
make, send them to:
John Newlin
Re: QCALC v. ______ (write in version number you're using)
66 Birchwood Drive
Millington, NJ 07946
I should be at this address a while, considering I'm out of
college, can't get a job, and leeching off the parents still
seems like a good idea. Also, by the way, this is the address to
send your checks too. (And just in case there's confusion, put
MY name in the "TO" portion of the check. It's a bit difficult
to cash checks made out to "QCALC", because my driver's license
says John Newlin.)
Enjoy, all.
"If you weren't keeping me hostage in the bathroom,
I might agree with you that I should pay for the door."
- John Newlin
_________________________________________________________________
Quick-Calculator -- Copyright (c) 1991 John Newlin -- Page 27