home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Lion Share
/
lionsharecd.iso
/
dos_misc
/
qcalc113.zip
/
WELCOME.QC
< prev
Wrap
Text File
|
1991-10-30
|
6KB
|
209 lines
;
; WELCOME.QC -- An Introduction to the Fundamentals of QCALC
;
;
; To run this script, type: QCALC @WELCOME
;
#
#Welcome to QCALC! This script file will guide you through the
#fundamentals of QCALC. At anytime you wish to abort this script,
#hit ESCAPE.
#
#This tutorial will pause frequently to wait for you to finish reading
#the information it is telling you -- when you are finished waiting, hit
#any key (the spacebar, for instance).
#
#In places that you see "<- YOU TYPE" on the right side of a line, that
#line is an example of what you can type on a command line on your own.
#
#Ready to Start? (Hit a key!)
~ ; Pause
#
#
# What is QCALC?
#
#
#QCALC is a command line calculator. That is, you tell it information
#by putting it on the command line. For example, let's say you want to
#add a few numbers (ten, twenty, thirty, and forty) together. This is
#how to tell QCALC to add some numbers:
#
#QCALC 10+20+30+40 <- YOU TYPE
#
#QCALC will add the four numbers together, and give you the following
#result: (Hit a key when ready.)
~
#
10+20+30+40
#
#And there's your answer. QCALC can calculate many different kinds
#of expressions. All you have to do is, at the DOS prompt, type
#the program name (QCALC) a space, and then your expression. Hit
#enter, and voila, your answer.
#
#Let's take a look at the different kinds of operators one can use
#in a QCALC expression. (Hit a key)
~
#
# Addition:
#QCALC 3+2 <- YOU TYPE
3+2
#
# Subtraction:
#QCALC 3-2 <- YOU TYPE
3-2
#
# Multiplication:
#QCALC 3*2 <- YOU TYPE
3*2
#
# Division:
#QCALC 3/2 <- YOU TYPE
3/2
#
# Modulus:
#QCALC 3%2 <- YOU TYPE
3%2
#
# Power:
#QCALC 3^2 <- YOU TYPE
3^2
~
#
#You can have more than one expression on a command line, just by
#separating them with a space.
#
#QCALC 3+2 3-2 3*2 3/2 3%2 3^2 <- YOU TYPE
#
3+2 3-2 3*2 3/2 3%2 3^2
~
#
#Operators have different "precedences." That is, the multiplication
#operator (*) has a higher precedence than the addition operator (+)
#-- it is evaluated first. Consider the following expression:
#
#QCALC 2+3*4 <- YOU TYPE
#
#What do you think the answer will be? 2+3 is 5, and 5*4 is 20.
#However, take a look at QCALC's answer:
#
~
2+3*4
#
#The answer is not 20, because multiplication is evaluated before
#addition. 3*4 is evaluated first (to 12), and then 2 is added to it.
#
#(Read the section of the QCALC.DOC manual "Precedence and Operators"
#for more information.)
#
#So, what does one do when one wants to ADD before MULTIPLYING? Use
#parethenses.
#
#QCALC (2+3)*4 <- YOU TYPE
#
~
(2+3)*4
#
#The parenthesis have the highest precedence, and override all others.
#This forces QCALC to evalute the addition operator before the
#multiplication operator, and thus produces the answer 20.
#
#Now we can get into the fun stuff: Variables. You can take the answer
#of an expression, and put it "aside" for later use. That is, you
#can use it later on the command line. Consider the following:
#
#QCALC 3*(2^8) 4*(2^8) 5*(2^8) <- YOU TYPE
#
#What a pain to retype (2^8). Using variables, you can do this:
#
#QCALC myvar:2^8 3*myvar 4*myvar 5*myvar <- YOU TYPE
#
~
myvar:2^8 3*myvar 4*myvar 5*myvar
#
#This assigns the result of the expression "2^8" to a variable named
#"myvar", and reuses myvar several times in the next expressions.
#The greatness of variables comes through when you use "on the fly"
#variables.
#
#QCALC !myvar 3*myvar 4*myvar 5*myvar <- YOU TYPE
#
# Type in a number (or valid expression):
!myvar
#
#Now, we can the result of the expression you entered in our
#following expressions. Watch this again:
#
~
3*myvar 4*myvar 5*myvar
#
#Variables can make things easier. A few variables are already defined
#by QCALC. (For example, "pi".) Variables can be redefined later on
#the command line.
#
#The last fundamental for QCALC are functions. QCALC has over 45
#mathmatical functions for you to use. Let's examine a few.
#First, let's take a look at "min". MIN takes two parameters, and
#returns the smaller of the two. Watch:
#
#QCALC min(5*5,1e+2) <- YOU TYPE
#
~
min(5*5,1e+2)
#
#Here's MAX, which reports the largest of its two parameters:
#
#QCALC max(5*5,1e+2) <- YOU TYPE
#
~
max(5*5,1e+2)
#
#For list of QCALC's functions, you can use QCALC's "/L" switch:
#
#QCALC /L <- YOU TYPE
#
#QCALC supports most basic math functions. For a better description
#of functions, read QCALC.DOC's section on "Functions".
~
#
#That ends our Getting Started tour of QCALC. You were taught by
#a script file, which (as you saw with the !myvar example) can be
#helpful as an interactive mathematical tool, especially when the
#variables are dynamic and the model is (more or less) static.
#QCALC can do a lot more than you've seen.
#
#Take a look at the other QCALC scripts (they all end with a .QC
#extension) and read the manual (QCALC.DOC) for more help. Also,
#experiment with the many switches and options QCALC offers.
~
#
#This tutorial was thrown together at the last moment by the author.
#If you can design better script files/tutorials, I would be happy
#to include them in QCALC's next release.
#
#Enjoy QCALC!