Dec 062017
 
QB 4.5 Auto scaled line graphs in EGA (source).
File LINEGRPH.ZIP from The Programmer’s Corner in
Category BASIC Language
QB 4.5 Auto scaled line graphs in EGA (source).
File Name File Size Zip Size Zip Type
LINEGRPH.BAS 11499 3134 deflated
LINEGRPH.DOC 5045 2374 deflated
TPCREAD.ME 199 165 deflated

Download File LINEGRPH.ZIP Here

Contents of the LINEGRPH.DOC file


E. R. Sebol September 1989
10610 Gorman Rd.
Laurel, Md. 20707

------- LINEGRAPH --------

An auto scaling line graphing program written in Quick Basic 4.5. It uses
screen 9 (640 x 350) resolution. You will need a color monitor and EGA to
use it as is but it can be converted to CGA or VGA if you are into counting
pixels.

This program is offered as public domain. I do not (you're on your own)
accept any responsibility for the consequences of any errors in this
program but I have checked it quite carefully and I am not aware of
any problems. If you find any peculiar problems, please let me know.

If, like me, you do some occasional technical programming and have
been frustrated by the absence of a program for on-screen presentation
of your results in the form of a line graph, this program may be useful.
I know that a file can be written to disk that can be made compatible
with other programs such as spread sheets, however, that seems too slow
and in the interest of interactive programming I felt that QB 4.5 and I
would be happier with a graphing program that was a QB subroutine.

I looked high and low on several bulletin boards but there was not
anything of this sort that I could find. It took three days to come up
with this program but when the work was finished I felt that a useful
general purpose tool had been created and I hope you think so too. If you
have found or written something better I would like to hear of it. I
am a novice at programming and will not be insulted by learning of such a
superior program. Eventually our MIS office will process the order I have
placed for a commercial version of a Quick Basic graphing program and this
one may be retired. Meanwhile, it is all I can get my hands on and it is
free! I presented it as source code to give maximum freedom to the user.
It has plenty of 'comments should you wish to get into it in detail. If
not, you may wish to save memory by editing out the comments. That is
up to you but I suggest that you set aside one virgin version.

The main module is a quick and dirty program that works with a trivial
two points. Nevertheless, it will allow you to see how the graphs look
and it will serve as an example of the calling technique. I suggest that you
try values that are:
0,0 and 3,3
0,0 and 1000,1000
1,1 and 1.2,1.2
-1,-1 and 1,1
-1,-1 and -9,-9
-1,-1 and 300,300
3,3 and 6,6
That will give you an idea of what it does any way. For serious use,
the number of points can be huge but two were enough to give it a test drive.

At first, the scales may seem strange but if you examine the values you will
discover that each minor division is a power of ten times one of the following
numbers: 1, 1.5, 2, 2.5, 4, 5, and 8. It might be somewhat easier to read the
graphs if the zero lines (which are in red) always were at one of the minor
grid lines but that would have reduced the resolution for many max and min
value combinations. That is the difference between presentation and science.
I went for maximum resolution rather than maximum convenience but at least
you won't have to deal with something goofy like 3.14159... units per box!
That is, it was intended to allow interpolation using mental arithmetic.

Dimensioned arrays are what it works with. One array is the set of X
values and the other is the set of Y values. I did not set a trap for
unequal sizes of the two arrays but you can easily add one since the
program is in source code which you can edit as you may feel the need.
In addition to the two arrays, the graphing subroutine calling parameters
include a title, X and Y axis labels, and the number of points in either
X or Y (either because they are equal).

The most difficult part of writing this program was figuring out how to
prevent round off error from confusing the IF-THEN-ELSE tests. If you look
at the listing, you will see some odd figures several places to the right of
the decimal in many branching tests. That is what it took to make the program
behave. A cute surprise was that QB-4.5 uses more precision while it
calculates a line than when it is finished. For example:
case 1.
A=log(10!)
B=INT(ABS(LOG(x)/A))
case 2.
C=INT(ABS(LOG(x)/log(10!)))

B=C right? I wish! Try it with x=100 and you will discover that B=1 and C=2 !!!
I even found a case where INT didn't even produce the next lower integer.
That is the kind of thing I mean. That is also why I am less than 100%
sure I have found all the quirks. There may be some values at the hairy edge
of a test edge that fall on the wrong side from where they should.
If any such quirks have escaped the search and destroy quest, it won't be
because I didn't look. I spent hours throwing cases at it to check it out.

Well, enough chit chat. Good luck. Enjoy.

--- Ron ---


 December 6, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)