Siebel eScript Language Reference > Siebel eScript Language Overview > Functions in Siebel eScript >

Error Checking for Functions in Siebel eScript

Some functions return a special value if they fail to do what they are supposed to do. For example, the Clib.fopen() method opens or creates a file for a script to read from or write to. If the Clib.fopen() method is called and is unable to open a file, then the method returns null.

If you then try to read from or write to the file that is assumed to be open, you receive errors. To prevent these errors, check whether Clib.fopen() returns null when it tries to open a file, instead of calling Clib.fopen() as follows:

var fp = Clib.fopen("myfile.txt", "r");

check to make sure that null is not returned:

var fp = Clib.fopen("myfile.txt", "r");

if (null == fp)
   TheApplication().RaiseErrorText("Error with fopen as returned null " +
   "in the following object: " + this.Name() + " " + e.toString() + e.errText());

You may abort a script in such a case, and the error text indicates why the script failed. See The Clib Object.

Siebel eScript Language Reference