comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: IDLVM and execute
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: IDLVM and execute [message #79020] Tue, 24 January 2012 16:25 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
This problem has been a problem for me before so I wrote a simple
arithmetic parser:

docs: http://docs.idldev.com/idllib/analysis/mg_evalexpr.html
source: http://docs.idldev.com/idllib/analysis/mg_evalexpr.pro

Evaluates a mathematical expression using the basic arithmetic operators
+, -, *, /, and ^ along with parentheses for grouping and simple
function calls of a single variable.

This routine does not use `EXECUTE`, so it is safe to use in the Virtual
Machine.

For example, simple arithmetic expressions can be evaluated::

IDL> print, mg_evalexpr('1 + 2 + 3', error=error), error
6 0

Note that the `ERROR` keyword returns whether there was an error in
evaluating the expression. Expressions can also take variables, if their
values are provided via a structure or hash-like object::

IDL> print, mg_evalexpr('exp(i * pi)', { pi: !dpi, i: complex(0, 1) })
( -1.0000000, 1.2246468e-16)

Mike
--
Michael Galloy
www.michaelgalloy.com
Modern IDL, A Guide to Learning IDL: http://modernidl.idldev.com
Research Mathematician
Tech-X Corporation
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: reads/readf into structures with explicit format
Next Topic: Re: To read excel file in IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 17:14:48 PDT 2025

Total time taken to generate the page: 0.00430 seconds