[fpc-pascal] Resolving math expression as input from user

Sven Barth pascaldragon at googlemail.com
Tue Apr 23 12:27:18 CEST 2019


Am 23.04.2019 um 12:04 schrieb James Richters:
> I'm trying to figure out if there is some function available that would take a string as input and return a double value that is the complete evaluation of the string?
>
> So when asked for a numeric input, the user could just put in a number like 6.28 but also put in a formula like SQRT(2) or (3*(8+Q))/9.3 or Hypot(I,J).... etc... using any random math operations in combination with math functions and variables,  without editing the code to create an expression to evaluate the formula.
>
[snip]
> Any Ideas?
You could take a look at fpexprpars. See also here: 
http://wiki.freepascal.org/How_To_Use_TFPExpressionParser

Regards,
Sven



More information about the fpc-pascal mailing list