Jerry White
Atari sound and graphics are great for game programs. In this monthly graph program, you will see how they can also be used to display data.
Data is often processed and compared on a monthly basis. Reports are generated to monitor things like cash flow or production. Sometimes it is much more meaningful to see totals in bar graph form rather than trying to compare a list of numbers. Using this program, the user types in the monthly totals and the program converts these figures into a beautiful graphic display.
For those who like to know how programs work: I'll break this one down and explain what each section is doing. For those who don't care: just key in the program and input your totals next to the appropriate month. The program will do the rest.
We begin by dimensioning A$ for use as a work string and two numeric arrays to hold 12 items. We go to the subroutine at 2000 and get our monthly totals and return to line 4. Here we get into graphics mode 6 with the text window at the bottom. We position our graphics window X and Y coordinates using PX and PY and put our heading into A$. Now we're off to the subroutine at 20. We will use this routine to convert our scratch string so that we can put text in the graphics window. Returning to line 8 - we use color 1 and draw a large rectangle. This is where we will draw our data bars. At line 100 we determine the highest amount (HAMT) so that we can base our key on that figure. The key will give meaning to the lengths of the bars. We set J1 = HAMT divided by 65 which is the length of the longest bar that fits into our rectangle. At line 130 we determine the top position of each bar. Then we make the top key figure (K) into a one or two position number and compute the numbers that will appear along the left side of the graph. At line 240 we begin to position and place our key of the screen. Then we set the screen margins as wide as possible and put the abbreviations for each month in the text window directly below the bar it represents. At line 310 we begin to draw our bars.
Being quite fond of sound, I couldn't resist adding line 360 as a finishing touch. This loop creates a tone as each bar is completed. Our purpose was to display data. Why not let the user use his ears as well as his eyes? Before we exit - we set the screen margins back to normal and loop at line 500. You could replace 500 with an end or exit routine. If you remove the first "? :" from line 300 there will be one line left in the text window for a message.
Program. Monograph Rev. 2
Download (Saved BASIC)
Download / View (Listed BASIC)
Return to Table of Contents | Previous Section | Next Section