Error checking for functions
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. But suppose that the computer is unable to open a file. In such a case, the Clib.fopen() method returns null.
If you try to read from or write to a file that was not properly opened, you get all kinds of errors. To prevent these errors, make sure that Clib.fopen() does not return null when it tries to open a file. Instead of just calling Clib.fopen() as follows:
var fp = Clib.fopen("myfile.txt", "r");
check to make sure that null is not returned:
if (null == (var fp = Clib.fopen("myfile.txt", "r")))
ErrorMsg("Clib.fopen returned null");
You may abort a script in such a case, but at least you will know why. See the section on the Clib object.