aboutsummaryrefslogtreecommitdiff
path: root/pkg/language/doc/defpac.hlp
blob: bc26234701e1f715fae2aa0afae77c877eda925a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
.help "defpac,defpar,deftask,defvar" Feb86 language
.ih
NAME
.nf
defpac  -- test if the named package is defined
deftask -- test if the named task is defined
defpar  -- test if the named parameter is defined
defvar  -- test if the named environment variable is defined
.fi
.ih
USAGE
.nf
defpac  (pacname)
deftask (taskname)
defpar  (param)
defvar  (variable)
.fi
.ih 
PARAMETERS
.ls pacname
An IRAF package name.
.le
.ls taskname
An IRAF taskname.  It may be specified as "taskname" or as
"packagename.taskname".
.le
.ls param
An IRAF parameter name.  It may be specified as "paramname",
"taskname.paramname" or "packagename.taskname.paramname".
.le
.ls variable
An environment variable name.  It may be specified as "varname".
.le
.ih
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 \fItask\fR
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 \fIbye\fR 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 \fIset\fR or \fIreset\fR statement.
.ih
EXAMPLES
1. Test if a task exists.

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

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

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

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

.nf
	cl> if (defvar("IRAFARCH")) {
	>>>    print ("IRAFARCH is " // envget("IRAFARCH")
	>>> }
	>>> ;
.fi
.ih
SEE ALSO
package, task, redefine, lparam
.endhelp