For Programmers: Free Programming Magazines  


Home > Archive > Fortran > April 2006 > how to evaluate an expression saved in a character string









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author how to evaluate an expression saved in a character string
Sear

2006-04-20, 7:04 pm

Hello, All,
Suppose I have a character variable arg: character(32)::arg='a+b'

and two integer variables a,b: integer::a=1,b=2

is it possible to evaluate the expression saved in string "arg" to get
the result 3 ?

Thanks


Zhen

beliavsky@aol.com

2006-04-20, 7:04 pm

Sear wrote:
> Hello, All,
> Suppose I have a character variable arg: character(32)::arg='a+b'
>
> and two integer variables a,b: integer::a=1,b=2
>
> is it possible to evaluate the expression saved in string "arg" to get
> the result 3 ?


Not in a trivial way, but I think the

Fortran 90 function parser at
http://itsextern.its.uni-karlsruhe....ionparserE.html

and the Function Parser at
http://smidgley.customer.netspace.net.au/fortran/

can do this.

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com