[futurebasic] Re: [FB] Maths Equation Editor

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 2001 : Group Archive : Group : All Groups

From: "Ashley Butterworth" <macbse@...>
Date: Thu, 5 Jul 2001
>I'm not sure how much help this will be, but here is a working example of 
>a short recursive fn that will evaluate a string using the 4 calculator 
>fns, exponentiation and parentheses. It can easily be expanded to handle 
>many other operators. This kind of recursion may be what you need for 
>your program.
>
>It works by successively dividing the expression into blocks (as you 
>described) and calling the fn again to evaluate each block before 
>recombining them with the appropriate operator.
>
>The order appears backwards because the first operators to be applied are 
>found at the bottom end of the CASE statement, but if you step through an 
>example in the debugger, you'll find that those priority operators are 
>actually performed before the others.
>
>This is just a template--it has absolutely no error or syntax checking! 
>However, if you feed it a correct expression, it will handle it.
>
>There are undoubtedly better ways to do this than working entirely with 
>strings--you would probably parse the elements first, putting them in an 
>array, then use a fn like this one to evaluate the array. 

Jay,
  Thanks, I've just taken a look through it and it looks pretty good, excpet that all I am intrested in doing is drawing it but this should be easily adapted for that.

  I've also had some more ideas on how to do this, using a recursive fn method, so I'll see what method pans out as the easiest and go with that.

  Once again thanks,


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com