home *** CD-ROM | disk | FTP | other *** search
- GRAPHIC SOLUTIONS for COMAL 0.14
- by Lowell Toms
-
- Recently, I ran across a new hand
- held calculator which was able to
- plot functions on a slightly
- oversized LCD screen. Well, it was
- pretty neat, but the last thing I
- need is another calculator. While a
- graphing routine may be a chore to
- program in BASIC, COMAL is a natural
- for the task. Before you skip on to
- the next program while mumbling who
- needs another graphing routine, you
- should know that this one has some
- different capabilities. The routine
- can plot up to six equations (y=f(x))
- on the same screen. These equations
- are entered and deleted while the
- program is running. The range and
- origin of the X and Y axes are easily
- modified from within the program.
- Finally, a joystick controlled
- routine prints the coordinates of any
- interesting point to the screen. This
- eliminates the need for an extensive
- grid, and gives much more accurate
- results than the eyeball approach.
- Hopefully, I've piqued your curiosity
- enough that you're ready to load the
- program.
-
- Graphic'solutions includes four
- different processes. When the initial
- menu screen appears you may select to
- enter a function, define the axes,
- plot a function, or find a point on
- your plot. Select 1 and a new menu
- appears which allows you to enter a
- function, view previously entered
- functions, clear all functions, or
- return to the main menu. Select 1
- again and you are asked in which
- position (1-6) you want to place your
- function. If you hit <RETURN>, the
- function is automatically placed in
- the first open position, (enter
- another number to overwrite a
- previous entry). Now, you are asked
- to enter your function:
-
- Y=X^4+5*X^3-7*X^2-29*X+30
-
- The computer pauses for a moment
- while the formula is entered. If
- you've made a syntax error in the
- formula, the program stops and an
- error message is displayed. Just
- correct the error and hit <RETURN>
- until each displayed line is entered
- and RUN sends you back to the main
- menu.
-
- Now, let's set the axes. Select 2,
- and you are asked to specify the
- origin. For this case, hit <RETURN>
- and the default values of 0,0 are
- entered. Next, you're asked to set
- the x tic marks. Hit <RETURN> and the
- default value of 1 is entered. For
- the y tic marks, enter 10 and hit
- <RETURN>. The next question asks if
- you want the origin and tic values
- displayed on the graph. Hit <RETURN>,
- and the values will be displayed. The
- main menu is displayed again, with
- the new values shown below the set
- axes selection.
-
- It's finally time to plot. Select 3
- from the menu, and then select 1 from
- the plot menu. Enter 1 (or -1 for
- faster, but cruder plot) of function
- 1. When the function plot is
- complete, a > appears in the upper
- left corner. Hit any key, and you
- will return to the plot menu. Type 3
- to return to the main menu, and
- select 4.
-
- Selection 4 is the joystick point
- finding routine. Plug your joystick
- into port 2, select 1, and hit
- <RETURN>. The plot reappears with the
- turtle present at the screen center.
- The turtle speed can be varied by
- pressing the + and - keys. Move the
- turtle to the point of interest and
- hit the fire button. The point's
- coordinates are displayed in the
- lower right corner.
-
- You're certainly not limited to
- graphing polynomials. Set the axes
- back to their default values (type 2
- from the main menu and then hit
- <RETURN> to all the prompts). Enter
- Y=TAN(X) keeping the same axes as
- before. Next try Y=1/X. This equation
- will create an error at x=0 unless
- you answer y to the avoid a point?
- query in the plot section and enter 0
- as the point to avoid. Some functions
- such as SQR don't digest negative
- numbers very well so you have the
- option of specifying positive x
- values only. Of course you could just
- shift the axes, but you may wish to
- plot another function on the same
- screen without a shifted origin. The
- plotting option also allows automatic
- plotting of all the entered functions
- by selecting 7 (or -7). You must
- press a key when the > appears, but
- the routine starts plotting the next
- function instead of returning to the
- menu.
-
- I was forced to make some compromises
- in the program due to the 12k
- available memory (and my inexperience
- with COMAL). The most serious
- compromise was the elimination of the
- bulk of the code comments. Even with
- minimal comments, the free memory
- available is only about 1/2k, so you
- may want to watch the memory size if
- you enter large formulas. (You must
- have an expanded memory version of
- COMAL 0.14 to run this program. The
- HI program on this disk expands
- memory.)
-
- Another warning is also in order. Do
- not renumber the first section of the
- program (lines 1-999). This section
- is the area where the dynamic
- keyboard routine modifies program
- lines. There is no screen dump
- utility built into the program, but
- there are plenty of dump routines
- available (try the Utilities #2).
-
- I hope you enjoy the program, and I
- would like to thank Dick Klingens for
- his STR$ and VAL routine listed in
- COMAL Today #12.
-