Board index » delphi » Input an equation
AM la Grang
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
|
AM la Grang
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Input an equation
Could somebody kindly help me.
I would like to readln an equation, for example: 5*9-2/3, or whatever, If there is a(n) (easy) way of doing this, please let me know... Thanks in advance, |
ya..
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Input an equationSomehow I don't think there is an easy way to do this. You'll have to make up some sort of parser to handle the expression, check out www.iecc.com/compilers/crenshaw/ that is a tutorial on compiler construction, but it has several pages about expression parsing. Good luck. |
Ing. Franz Glase
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Input an equationQuoteya...@ravine.binary.net wrote: a parser (formula expression evaluator) on the TP-links site in the numerics chapter and in the sources chapter. Look for Pedt Scragg's parser and some more. Even a very old http://www.geocities.com/SiliconValley/2926/tp.html Franz Glaser |
Timo Sal
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Input an equation27) How to evaluate a function given as a string to the program? 149061 Jul 19 1998 ftp://garbo.uwasa.fi/pc/link/tsfaqp.zip All the best, Timo .................................................................... Spam foiling in effect. My email filter autoresponder will return a |
corb..
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Input an equationIn article <6pvcn0$lf...@news2.saix.net>, "AM la Grange" <alagra...@intekom.co.za> wrote: Quote> I would like to readln an equation, for example: 5*9-2/3, or whatever, (such as Delphi), then download a copy of UCalc Fast Math Parser from http://www.ucalc.com/dll . Daniel Corbier, UCALC -----== Posted via Deja News, The Leader in Internet Discussion ==----- |
Dr John Stockto
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Input an equationJRS: In article <6pvcn0$lf...@news2.saix.net> of Sat, 1 Aug 1998 17:36:10 in comp.lang.pascal.borland, AM la Grange Quote<alagra...@intekom.co.za> wrote: routines. If you have BP7, there is the possibility of reading the line(s), Alternatively, http://www.merlyn.demon.co.uk/programs/longcalc.pas, NOTE : In it, #uf, #sd, #ds, whilst plausible, are not yet correct. -- |
Pedt Scrag
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Input an equationIn article <35c8c2af.5474...@nntp.ftc-i.net>, Higgi...@ftc-i.SpAmZaP.net writes Quote>On 1 Aug 1998 16:00:42 GMT, ya...@ravine.binary.net wrote: easier to allow the standard operators such as sqrt etc. Quote
the input line sequentially. Sqrt and suchlike just need to have their arguments parsed, parantheses are a bit harder to work with but can be dealt with. Reals can be dealt with by looking for the decimal point. One thing to remember with this is that you should look for "sqrt" There's an example of a parser that will do this available via -- Never curse the Crocodile's mother before crossing the river |
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Input an equation |
Antivivisektion e.
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Input an equationQuoteAM la Grange wrote: [Expression-Compiler (OOP/TP55-TP70)] You may use it like in my example below: | Uses Math; Quote> If there is a(n) (easy) way of doing this, please let me know... You may also use one-char variables to evaluate complex expressions: | Uses Math; The expression may be as complex as you wish, It's even possible to add your own functions at runtime, e.g. RANDOM: | Uses Math; The error-handling (simple HALT) has to be worked out... -- A.E.Neumann fr die Antivivisektion e.V., PO-Box 201, D-53569 Unkel [Animal research is wasteful and misleading] |
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Input an equation |
Virtu
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Input an equationAM la Grange (alagra...@intekom.co.za) wrote: Quote> Could somebody kindly help me. a program that did exactlyt what you need. If there's an interest I cab post the source sometimes. Having fully parenthesized expressions make the parser somewhat simpler. |
Mark Grindel
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Input an equationIf I can find it, quite a long time ago I wrote a pascal program for doing automatic differentiation. It worked quite well, and included a parser just like the one you seem to need. However, it is probably true to say that the bulk of the program is a bit difficult to understand, as it includes the differentiation part, and a reducer/factorer (which never got finished to my satisfaction). Hardly surprising - this is a very hard problem, much harder than the differentiator! Interested? (I hope to goodness I've still got it somewhere!) |
AM la Grang
![]() Delphi Developer |
Wed, 18 Jun 1902 08:00:00 GMT
Re:Input an equationHi there... I only arrived home just now (I'm at boarding school). But yes, please, Thanks so much... A la Grange, Aliwal North, South Africa QuoteVirtual wrote in message <35c6606...@news.pacifier.com>... |