SCIENTIFIC PROGRAMS WRITTEN IN BASIC (for PCs)


If you are unfamiliar with the old BASIC computer language, then please read this first. But if you are an expert in BASIC, then just skip down to the programs.

Below are some old freeware science programs for PCs, written in the old BASIC language, that I wrote many years ago (around 1989). They range from ridiculously simple to almost sophisticated. I recently rediscovered the programs when I was cleaning my house. Rather than throw them away, I thought I'd put them on the web. Best of all, they are guaranteed to be virus free and they won't cost you a cent! I hope you enjoy using them.

PLEASE NOTE: You must do the following:

1) You must have a PC with an operating system that can open a DOS window (or a PC that can boot to DOS).

2) Make sure you have a copy of GWBASIC.exe, BASICA.exe, or QBASIC.exe already installed on your computer. You need one of these to run BASIC programs. If you don't have one of them, you should be able to find a copy on the Web. If you are using Qbasic and are having trouble getting the programs to load and run, read how to easily fix the problem.

3) Save the file to your computer (Click "Files", then click "Save As").

4) After you have saved the file to your computer, carefully look over the program code and make sure that each numbered line is on one line. In most cases, you can ignore this step. Go to step 5. However, if you see a numbered line that occupies two lines ("word-wraps"), then edit that particular line so that all of the code is on one numbered line. Word-wrapped program code is forbidden. Do not edit the file with a text editor that word-wraps!

5) RENAME the file with a .bas extension. The file name can be up to 8 characters long (that's because of DOS's archaic file-naming limitations!). The .bas extension is the important part. Example: You should change eventti.txt to eventti.bas

6) To RUN the program, you must first open a DOS window and then run the BASIC interpreter. In the case of GWBASIC, open a DOS window and then type: gwbasic.exe and press (ENTER).
(Or you can create a Windows shortcut to GWBASIC. Then all you have to do is click on the GWBASIC icon).

7) After the GWBASIC interpreter program has started, type FILES and press "ENTER". BASIC will then show you a list of your programs.

8) To RUN a program, type:
load "filename.bas"
and then press (enter). (include the " " marks around the program's name).

9) Then type: run

10) To exit BASIC and return to Windows, type: system
and press (enter). Some of my programs automatically do this.

11) To exit a BASIC program while it is running: While holding down the CTRL key, press the PAUSE key. After the program stops, type: system
and press (enter).
You should now be back in the Windows environment.

12) TROUBLESHOOTING:
    •If you are using Qbasic and are having trouble getting the programs to load and run, read how to easily fix the problem.

    •If the program still does not run, it is probably because one or more program lines are word-wrapped (see step #4, above). [Footnote: When the program is later loaded into GWBASIC.exe, any long lines will automatically word-wrap. This is normal and okay. If this is confusing, don't worry]. Just make sure that the .txt file has no word-wrapped numbered lines.

    •If you try to load the program and BASIC says that the program cannot be found, make sure that your file resides in the same folder or directory as your BASIC interpreter program (BASICA.exe, GWBASIC.exe or QBASIC.exe). Also be sure that your file has a .bas extension. If it has a .txt file extension, then rename it with the .bas extension.

    •In some cases, GWBASIC will show you the offending line of code when you attempt to RUN the program. If so, simply make corrections to that line and press (enter). The cursor must be placed on the line of code when you press (enter). Then RUN the program again and see if that solves the problem. If everything works, be sure to SAVE the program to preserve the changes. To SAVE a program when running GWBASIC, type:
    save "filename.bas"
    and then press (enter)

    •GWBASIC/BASICA and Qbasic allow a maximum of only 8 characters in the file's name.

    •Do not confuse Visual BasicTM for Windows with the various BASIC interpreters. Visual BasicTM cannot run BASIC programs.



HERE ARE THE BASIC PROGRAMS

(these programs will run on BASICA, GWBASIC, and Qbasic)

(be sure to rename the file exensions of the programs, below, from .txt to .bas)


gr-circl.txt
This program computes great circle distances between any two points on the earth if their latitudes and longitudes are known. It also calculates the antipode for any location on Earth, and it can compute the Earth's rotational velocity for any latitude.

appa-dip.txt
A structural geology program that calculates the "true dip" angle of a rock bed if you know: 1) the "apparent dip" angle of the bed (as seen in a highway road cut or outcrop); 2) the strike of the dipping bed; and 3) the strike of the road cut on which the "apparent dip" angle is observed.

eventti.txt
This program will record the date and time of any event or events whenever a key is pressed. The program saves the events and their times to a text file. It is useful for recording and tabulating events. It also makes an "okay" stopwatch (accurate to one second).

g-calc.txt
Do you have a laboratory centrifuge and you want to know the 'g' for a given RPM? Or do you want to play around with artificial 'gravity' experiments? This little calculator will calculate acceleration (and 'g') for any given radius of rotation and rotation rate.

timer.txt
This is a simple timer/alarm clock program. You can set the alarm for weeks or months in advance (of course, your computer must be running continuously (duh)). The timer/alarm is accurate to one second. The alarm now includes DB-9 serial port (on COM 2) output as an option! (in order to utilize the serial port output option, your computer must have a serial port, or if you have a PC with the newer USB bus, then you will need to buy a USB card that emulates the old serial port).

point-co.txt
This geology program uses the computer's keyboard as a tabulating device for point counting sedimentary rocks in thin section (each key is programed to represent a specific mineral). The program also gives ternary percentage summaries and other statistics, and it saves the results to a text file. With a little tweaking, it could be adapted for point counting volcanic rocks in thin section.

prime-no.txt
A neat little program that uses a simple "brute force" algorithm to determine if an input number is a prime number. Really simple code. Can you improve it?

x-ray.txt
This X-ray diffraction (geology) program will convert d-spacing (in angstroms) into 2 theta (in degrees) or from 2 theta into d-spacing.

antipode.txt
This program will calculate the antipode for any point on the Earth. (The antipode is on the opposite side of the Earth from the input point. A straight line drawn through the center of the earth would connect the two points).

bivariat.txt
This program computes simple statistics (mean, standard deviation, and a correlation coefficient, and it computes a linear regression equation) for a bunch of X and Y data. The program saves these data and results to a text file.

h2o-pres.txt
This program computes ocean (salt water) pressure, in pounds per square inch, at any chosen depth.

sierpins.txt
Sierpinski's Triangle. This program demonstrates how some chaotic systems (such as a throw of a gaming die) can show structure when their effects are graphically plotted (graphical representations of chaotic systems, showing strucuture, are often called "attractors"). Sierpinski's Triangle, first described around 1900, is also a good example of a fractal. It is a useful demo program for math classes, statistics classes, and introduction to chaos theory.

tern-plt.txt
This geology program takes percentage results from point counts and plots them on a ternary graph.

tern-ran.txt
This is a program that plots randomly-generated trivariate data onto a ternary diagram. It is an example of a Monte-Carlo simulation. What I find interesting is that, with less than a few thousand plotted data points, the graph shows a clear structure (the points tend to congregate in and around the center of the diagram), but if millions of points are plotted, the graph will completely fill, indicating that the algorithm is indeed generating random numbers. I am at a loss as to what is going on. Do you have an explaination?

wave-en.txt
This program converts a given electromagnetic wavelength into its corresponding energy (in eV) or a given energy into its corresponding electromagnetic wavelength.

Hell Creek Life © 1997-2009 Phillip Bigelow