TURBO PASCAL |
Новости
|
27: How to evaluate a function given as a string to the program?A: To do this you have to have a routine for parsing and evaluating your expression. This is a complicated task requiring a clever use of recursion. You can find such code in Stephen O'Brien (1988), Turbo Pascal, The Complete Reference. Borland- Osborne/McGraw-Hill, Chapter 10. Another, simpler piece of code can be found in Michael Yester (1989), Using Turbo Pascal, Que, Chapter 5. I've also written such a function evaluation program myself, and much of it is based on the ideas in O'Brien with my own corrections and enhancements. The resulting program is available as fn.exe function evaluator in the ftp://garbo.uwasa.fi/pc/ts/tsfunc13.zip package (or whatever version number is the latest). Note however, that the source code is not included, nor available. Tips from Justin Lee (ossm1jl@rex.uokhsc.edu): 67666 Sep 22 03:00 ftp://garbo.uwasa.fi/pc/turboobj/parstp30.zip parstp30.zip Recursive expression TP7.0/BP/VB/C++ parser, R.Loewy An excellent parser is included with all the Turbo Pascal versions since TP4.0 as part of the MCALC or TCALC spreadsheet example program. See mcparse.pas or tcparse.pas. |
(с)Все права защищены По всем интересующим вопросам прошу писать на электронный адрес |