deftask: Test if a task is defined

Package: language

Usage

defpac  (pacname)
deftask (taskname)
defpar  (param)
defvar  (variable)

Parameters

pacname
An IRAF package name.
taskname
An IRAF taskname. It may be specified as "taskname" or as "packagename.taskname".
param
An IRAF parameter name. It may be specified as "paramname", "taskname.paramname" or "packagename.taskname.paramname".
variable
An environment variable name. It may be specified as "varname".

Description

These routines return a boolean value indicating whether the relevant parameter, task or package has been defined. A task becomes defined when the package to which it belongs is "loaded" by entering the name of the package as a command, or whenever a task declaration is input to the CL. A parameter becomes defined when the task to which it belongs is defined; the task need not be currently executing for its parameters to be defined. When a package is exited, e.g., after entry of the bye command, all the task and parameter declarations for the package are discarded. Environment variables may be either in the host environment, or in the CL environment as a result of a set or reset statement.

Examples

1. Test if a task exists.

cl> if (deftask ("system.page"))
>>>     print ("task page exists")
>>> else
>>>     print ("task page not found")
task page exists
cl>

2. Add the value of the named parameter into a sum, but only if the parameter exists (the example is for a script).

sum = 0
for (i=0;  i <= 10;  i+=1) {
    parname = "data" // i
    if (defpar (parname)
        sum += parname
}

3. Checked whether the 'IRAFARCH' environment variable is defined.

cl> if (defvar("IRAFARCH")) {
>>>    print ("IRAFARCH is " // envget("IRAFARCH")
>>> }
>>> ;

See also

package, task, redefine, lparam