PslFunctionExists()
Tests for the existence of a built-in PSL function.
Syntax
Parameter
Parameter | Definition |
---|---|
function_name | Name to be tested to determine if it exists as a PSL built-in function. User-defined functions are not supported. |
Description
The function returns a tuple of the following format if the specified function exists:
min,max
where min is the minimum number of arguments the specified function accepts and max is the maximum number of arguments the function accepts. If the function does not exist the empty string is returned. This function does not set the PSL errno variable.
The PslFunctionExists() function can be used to take advantage of new PSL functions or extended features of existing PSL functions while maintaining code paths that still work on older Agents or degrade gracefully.
Example
The following PSL statements demonstrate use of PslFunctionExists().
buf = "";
finfo = PslFunctionExists(fname);
buf = buf . "PSL built-in function \"" . fname;
if (finfo != "") {
buf = buf ."()\" exists.\n";
buf = buf . "It requires at least ";
buf = buf . ntharg ( finfo, 1, "," ) . " argument(s).\n";
buf = buf . "It accepts at most ";
buf = buf . ntharg ( finfo, 2, "," ) . " argument(s).\n";
} else {
buf = buf . "()\" does not exist.\n";
}
print (buf);
}
print_function_info ("get_vars");
if (PslFunctionExists("gethostinfo") ) {
print("Host information for localhost:\n" . gethostinfo ("localhost") );
} else {
print("Sorry.gethostinfo() is not available on this version of the Agent.\n");
}