About Chandra Archive Proposer Instruments & Calibration Newsletters Data Analysis HelpDesk Calibration Database NASA Archives & Centers Chandra Science Links

Skip the navigation links
Last modified: December 2006

URL: http://cxc.harvard.edu/ciao3.4/chips_eval.html
Hardcopy (PDF): A4 | Letter
AHELP for CIAO 3.4 chips_eval Context: chips

Synopsis

Call ChIPS commands from S-Lang

Syntax

Integer_Type chips_eval(String_Type)

Description

The chips_eval() function allows S-Lang code to execute ChIPS commands which do not have a corresponding S-Lang version. To do this, you create a string which contains the command to execute and pass it to chips_eval(), which returns a 0 on success and a -1 on failure.

Example 1

() = chips_eval("xlabel 'TIME (s)'");
() = chips_eval("xlabel size 1.5");

These two lines - if included in a S-Lang script which has already loaded the ChIPS module with a

require("chips");

call - will change the x-axis label to "TIME (s)" and the size of the label to 1.5.

We use "() = " to ignore the return value of the call (i.e. whether it succeeded or not).

Example 2

Defining S-Lang versions of ChIPS commands

The "chips_eval()" function can be used to write your own S-Lang versions of ChIPS commands. The example file listed below ("axis.sl") defines a S-Lang function called "xaxis()" which takes one argument - the label for the X axis. It uses "chips_eval()" to call the ChIPS XLABEL command twice; first to set the label axis and the second the size of the label. The use of "string(label)" means that the function can be called with a numeric argument (since the numeric value will be converted to a string by this function) as well as a string. Before calling XLABEL we turn off the redraw mode - using chips_auto_redraw() - to avoid the plot flashing. The original value for this mode is reset after the chips_eval() calls are made.

  unix% cat axis.sl
  define xaxis(label) {
    variable oldval = chips_auto_redraw(0);
    () = chips_eval( "xlabel '" + string(label) + "'" );
    () = chips_eval( "xlabel size 1.5" );
    () = chips_auto_redraw(oldval);
  }

This can then be used by:

  chips> () = evalfile("axis.sl")
  chips> xaxis("TIME (s)")

The evalfile call can also be included in your .chipsrc resource file to make sure the function is available each time you use ChIPS.

Bugs

See the bugs page for ChIPS on the CIAO website for an up-to-date listing of known bugs.

See Also

chips
chips
modules
varmm
sherpa
sherpa_eval
slang
math, overview, slang, tips, variables
tools
ascii2fits
Hardcopy (PDF): A4 | Letter
Last modified: December 2006



The Chandra X-Ray Center (CXC) is operated for NASA by the Smithsonian Astrophysical Observatory.
60 Garden Street, Cambridge, MA 02138 USA.    Email: cxcweb@head.cfa.harvard.edu
Smithsonian Institution, Copyright © 1998-2004. All rights reserved.