RETURN to the CHEM 498C Home Page
QuickBASIC Program Assignment
Spring 1996
This handout will describe the specifications of a program you are to write,
for the purpose of practicing laboratory-oriented BASIC programming in the
QuickBASIC environment.
Objective: The purpose of the program is to allow the user to compare
graphically an experi mental signal (set of points) to a calculated model
function and to adjust the model para meters manually in an effort to observe
how the model changes and how it compares to the data.
Specifications:
a. The experimental data are to be read from a sequential text file in x,y
format into a real (single-precision) array.
b. Use a Lorentzian peak on a flat background as the model function
with variable height, position, and width.
Z = (X - X0) / PeakWidth
Y(X) = Background + PeakHeight / (1 + Z * Z)
Where X is the manipulated variable, Y is the response variable,
X0 is the peak center position, PeakHeight is the height of the
peak, PeakWidth is the width of the peak, and Z is a dummy
variable. Evaluate the model function only over the x-range of the data and
for enough points to make a smooth curve (50 points should be enough), no
matter how many points the data have.
c. The data and the model are to be plotted superimposed on the graphic screen
at the highest resolution of the hardware you have available, using different
plotting methods to distinguish the two (e.g. dots or symbols for the data and
lines for the model, or different colors).
d. You are to devise some method of allowing the user to adjust the parameter
values while look ing at the graphic comparison, preferably not requiring the
user to retype an entire number just to make a small change. Suggestion: use
rows of adjacent keys on the keyboard to increase and decrease the value of a
parameter, e.g. the A, S, D,and F keys to change by -10,-1, +1, +10, or perhaps
6 or more keys in a row to gain wider and/or finer control. You can use the
INKEY$ function to read the keyboard on the fly. Display the current
values of all three parameters as they are being changed.
e. Don't use GOTO; use only structured programming practices. Indent your
loops. Strive to modularize your program and label the parts with comments.
f. Don't allow a simple user mistake to abort the program; protect the user
against "file not found" and other easily made errors.
Lab Report. Submit the source code on diskette as a ".bas" file. Due
March 26.
Grading: The program will be graded on the following basis, in
decreasing order of importance:
a. Functionality. Does the program meet the objectives?
b. Correctness and robustness. Are the data and model plotted correctly? Can
a simple user mistake cause the program to abort?
c. Structure, internal comments, and programming style. Can the program be
easy read, under stood, and modified by another programmer?
d. Instruction or help file. Is there a clearly written instruction sheet or
help screens that can be displayed from within the program?
This page is maintained by Tom O'Haver , Department of Chemistry and
Biochemistry, The University of Maryland at College Park.
Comments, suggestions and questions should be directed to
Prof. O'Haver at to2@umail.umd.edu.