From Peter Hughes · 1996-04-01 23:34 · #75499 in AMOS_ECHO
Hi Simon,
In a message of 28 Mar 96 Simon Esjay wrote to All:
SE> Hi all, I have a problem.......
SE> I am trying to code a mathsplotter in AMOS (No jokes please!). The
SE> problem I am having is that I want the user to be able to enter an
SE> expression to plot BUT I aint got a clue how to get the equation out of
SE> the expression string, and how to incorperate it into the plotting
SE> routine !!!
As in X=10*20/3.5
What I would do is to break it up into 3 sections.
Where the Variable X would equal:
The values would be held in the Variable A(3,3) (Should be a string)
You would use the INSTR function (INSTRing)
IE.
i=INSTR("10*20/3.5","*")
The Variable i would equal 3. By using a combination of MID$ and LEFT$
you should be able to split the function quite easily.
A(1,1) A(1,2) A(1,3)
10 * 20
A(2,1) A(2,2) A(2,3)
X / 3.5
To get the value of all this:
X=VAL(A$(1,1))
FOR T = 1 TO 2
IF A$(t,2)="+"
X=X+VAL(A$(t,3))
ENDIF
IF A$(t,2)="-"
X=X-VAL(A$(t,3))
ENDIF
IF A$(t,2)="*"
X=X*VAL(A$(t,3))
ENDIF
IF A$(t,2)="/"
X=X/VAL(A$(t,3)
ENDIF
NEXT T
TTFN
BTW if this is along the lines of what you want but you are unable to quite grasp what I mean let me know and I shall dust off my version of AMOS and send you an example.
Peter Hughes B.S.C. (Bronze Swimming Certificate)
--- Spot 1.2d Unregistered
* Origin: Origin: Talky Toaster. (2:441/93.22)