Getting Started Documentation Glish Learn More Programming Contact Us
Version 1.9 Build 1556
News FAQ
Search Home


next up previous contents index
Next: Manipulating Variable Argument Lists Up: Predefined Functions and Variables Previous: Manipulating Symbols


eval Function

The eval function is used to evaluate a string as a Glish statement and return the result. This is probably most useful for allowing users to enter Glish commands from a GUI. Here is an example of how eval is used:
    x := 10
    y := 18
    print eval("y +:= 2", "x * y")
In this example, the output is 200, and y equals 20. Currently, the strings passed to eval are always evaluated in the global scope. This is true even if eval is called from a function; this is a bug. The result is the following unexpected behavior:
    x := 10
    y := 18
    func foo() { y := 2; return eval("y +:= 2", "x * y") }
    print foo()
This example results in an output of 200 and the global y equal to 20 (the same as the previous example). This will hopefully be fixed in a later release.


next up previous contents index
Next: Manipulating Variable Argument Lists Up: Predefined Functions and Variables Previous: Manipulating Symbols   Contents   Index
Please send questions or comments about AIPS++ to aips2-request@nrao.edu.
Copyright © 1995-2000 Associated Universities Inc., Washington, D.C.

Return to AIPS++ Home Page
2006-10-15