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/paramio_pget.html
Hardcopy (PDF): A4 | Letter
AHELP for CIAO 3.4 pget Context: paramio

Synopsis

Get a parameter value within S-Lang.

Syntax

String_Type pget( paramfile, param )

Description

This function is essentially the same as the command-line version (see "ahelp tools pget"), although only one parameter - the param value above - can be accessed at a time. To use pget() the paramio module must have been loaded.

The parameter value is always returned as a string by this function; the paramio library does contain functions - such as pgetb() and pgetf() - which will automatically convert the value into the requested datatype, or you can use the S-Lang intrinsic functions to do this. The pquery() function may also be of interest.

Error handling

As with all the paramio routines, the PF_Errno variable is set to 0 on success, or on error it is set to one of the error codes listed in the paramio documentation.

Example 1

chips> punlearn("dmcopy")
chips> ifile = pget("dmcopy","infile")
chips> clval = pget("dmcopy","clobber")
chips> ifile

chips> if ( ifile == "" ) print("infile is empty")
infile is empty
chips> clval
no

Here we use pget() to find the current settings of the "infile" and "clobber" parameters of the "dmcopy" parameter file.

Example 2

chips> punlearn("dmcopy")
chips> fp = paramopen("dmcopy")
chips> ifile = pget(fp,"infile")
Input dataset/block specification (): in.fits
chips> clval = pget(fp,"clobber")
chips> paramclose(fp)
chips> ifile
in.fits
chips> clval
no

This example is similar to the first except that we use the return value of paramopen() to access the parameter file. If you make many paramio calls on a single parameter file then it is more efficient to use paramopen() than just using the name of the parameter file.

Since we did not supply a mode parameter for the paramopen() call, it defaults to "r" and so the paramater was prompted for when pget() was called.

Example 3

chips> punlearn("dmcopy")
chips> fp = paramopen("dmcopy","rH")
chips> ifile = pget(fp,"infile")
chips> paramclose(fp)
chips> if ( ifile == "" ) print("infile is empty")
infile is empty

By opening the parameter file with the mode set to "rH" we avoid the interactive prompt when pget() is called.

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.