First ST BASIC applicationby STEVE WHITNEY
When ST BASIC finally became available, I was determined to write a program that would demonstrate its real power. Several "biorhythm" programs had been floating around the public domain. "Why not?" I thought.
So, what are biorhythms? Good question. Biorhythms chart certain alleged biological rhythms (hence the name) which begin at birth and continue through life. There are Physical, Intellectual and Emotional rhythms.
These rhythms are simply, in essence, plotted sine waves (see Artistic Mathematics in this issue). When one of your biorhythms is at its highest point on the curve, your ability to deal with that area of your life is likely to be high. When a biorhythm is low, your ability may be dulled. But on days when a particular biorhythm is crossing the center axis (horizontal midline), it may be considered a critical time in your biorhythm. When more than one of the biorhythms cross that horizontal center line at the same time, it is considered to be a double or triple critical day. (Stay in bed!)
You might try keeping a record of how you feel on certain days and then, later, compare your observations with the biorhythm and determine their validity. I have tried this and found it to be quite accurate sometimes-but quite far off on other occasions. (We would like to add that many consider biorhythm analysis to fall into the same category as astrology-ST RESOURCE)
ST Biorhythms will run on any Atari ST regardless of resolution. Boot your ST and activate ST BASIC. If you have a lot of desk accessories or a large background program in memory, ST Biorhythms may not load. To overcome this, use your mouse to de-select Buffer Graphics from the Run Menu of ST BASIC. This will give you an additional 32K of memory. Type in Listing 1, BIORTHM.BAS, and SAVE a copy to your disk before you RUN it.
The program will full and clear the output window, then ask for your birthdate, name, and the month for which you wish the biorhythms plotted. When these are answered, the program will ask if you want the chart sent to the [P]rinter or the [S]creen. Choose [P] or [S] and the biorhythm begins printing out. When the chart is finished, press [Help] or [Esc] to end the program.
Let's examine Listing 1. You might have already noticed there are no gotos in this program. ST BASIC has features that make writing a goto-less program easy. Starting from the top, line numbers 1000-1050 are the program title. Lines 1070 to 1130 comprise the entire work loop in this program. And this loop does exactly what it says: while not finished, gosub BIORHYTHM. Eventually the program will be finished, and the program will end.
COUNTDAYS will count the number of days between birthtime and printtime. At one time or another it will call one of the four self-explanatory subroutines located below it, between lines 1270 and 1520.
Next, the main routine BIORHYTHM starts at line 1540. This routine will clear and full the output window, place the title along the top and gather in the desired birthdate, name, and month of printout. Limited range-checking is done on the information typed in, and the program proceeds to COUNTDAYS (line 1930), which counts the number of days between the birth date and the start of the displayable month.
Next, the program stops and asks for the desired output device. Select either [S]creen or [P]rinter (upper or lower case are both okay) and continue. Between lines 2060 and 2070, control is diverted to whichever output routine you choose.
Line 2110 is where the screen output subroutine ONSCREEN is located. It first clears the output window, then the subroutine FANCY will draw the displayed box and fill the background with a pattern. LABEL will print the labeling on the graph. Next, print the title along the top of the screen. Next, we have a nested for... next loop that will plot each of the cycles onscreen. Below that, perform a vdlsys() call to set the linewidth to 1 pixel wide, then stop in a loop-GETKEY-waiting for a keystroke.
The subroutine HELP prints a keystroke reminder onscreen. ONPRINTER is the routine that prints out the biorhythm chart onto paper. This routine as written will work on any Epson, Star Micronics, or Epson compatible printer, (such as an ADS-2000). It performs an ASCII dump, and as such does not require your printer to handle graphics.
CALC and FINDR are small number-crunching subroutines that are called from above in the output routines. LABEL and FANCY are described above, where they are called from.
INITIALIZE performs the initialization needed to run in any resolution. It determines the current resolution, initializes constants, and fills arrays with needed start-up information. Finally, INITLOREZ, INITMEDREZ, and INITHIREZ contain resolution-specific information.
Can you see the power of Atari ST BASIC? C'mon, all you ST BASIC Programmers out there! Let's show the world what the ST can do... BASICally.
Steve Whitney is a freshman at Stanford University, trying to decide whether to major in electrical engineering or computer science. His parents bought him an Atari 800 in 1982 and it all went from there.
Listing 1 BIORTHM.BAS