bool exists(string)
Return Type: bool
Parameters: string VarName
Description:
This function checks to see if a variable exists. The variable name is
passed as a string to the function. If the variable exists, the function
returns true. If it does not exist, the function returns false. The variable
exists if it is local to the function or a global variable.
Example
Code |
int
i = 10;
exception e; function
void F(int a){
real r = 32.2;
who();
if(exists("i") == false){
e.SetError("Variable i does not exist
(1)");
e.throw();
}
if(exists("a") == false){
e.SetError("Variable a does not exist
(2)");
e.throw();
}
if(exists("r") == false){
e.SetError("Variable r does not exist
(3)");
e.throw();
}
} who();
F(42); if(exists("a")){
e.SetError("Variable a exists (1)");
e.throw();
} |