Group: | Information and Control |
See also: | existglobal |
Function: | exist | |
Description: | Exist tries to find out whether the input object exists or not. If the object exists, the type of the object is given in the output window. |
Usage: | r = exist ("name") | |
Input: | ||
name | object name | |
Output: | ||
r | scalar |
-1 object does not exist
0 object is empty, in quantlets any object which has not been declared is empty
1 object is numeric
2 object is text
3 object has type XPLTIME
4 object is a display
9 composed objects (lists)
10 argument is a quantlet.
E.g., if there is an object 'corr=1' and the library("xplore") is loaded, using exist("corr") results in "11" in the outputwindow (meaning "10" because it is a quantlet and 1 as the object is numeric).
Exist does not find global objects because is works only locally.
If x is defined within the procedure and it is not a quantlet you can also use exist(x) instead of exist("x"). In this case the result can never be -1.
x = matrix(2,4) exist("x") z = createdisplay(1,1) exist("z") exist("y")
Contents of exist [1,] 1 ; because x is numeric Contents of exist [1,] 4 ; because z a display Contents of exist [1,] -1 ; because y is not defined