|AHELP for CIAO 4.2||
Get a parameter value within S-Lang.
String_Type pget( paramfile, param )
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.
The paramio module is not available by default; to use it in a S-Lang program, it must be loaded using the S-Lang require() function:
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.
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.
slsh> punlearn("dmcopy"); slsh> ifile = pget("dmcopy","infile"); slsh> clval = pget("dmcopy","clobber"); slsh> ifile; slsh> if ( ifile == "" ) print("infile is empty");; "infile is empty" slsh> clval; no
Here we use pget() to find the current settings of the "infile" and "clobber" parameters of the "dmcopy" parameter file.
slsh> punlearn("dmcopy"); slsh> fp = paramopen("dmcopy"); slsh> ifile = pget(fp,"infile"); Input dataset/block specification (): in.fits slsh> clval = pget(fp,"clobber"); slsh> paramclose(fp); slsh> ifile; in.fits slsh> 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.
slsh> punlearn("dmcopy"); slsh> fp = paramopen("dmcopy","rH"); slsh> ifile = pget(fp,"infile"); slsh> paramclose(fp); slsh> 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.
See the bugs page for the paramio module on the CIAO website for an up-to-date listing of known bugs.