Just FYI

Exit # is the "return code" - it should always be zero unless an error occurred, as it sets the @ERROR macro. This is valid only for user defined functions, or exiting the main script.

If you define a UDF called MyUdf(), you can also set a "return value" by loading the data you want to retun into a variable the same name as the UDF. Thus, if you want to return "42" from your MyUdf calculations, you would put this at the end of your UDF:
 Code:
$MyUdf = 42
Exit 0

However, if the calculation failed, you might do this at the point you detected the error:
 Code:
$MyUdf = 0
Exit 1

Exiting with 1 is "incorrect function" - a generic error. You can use many other, more meaningful error values. Some common ones are
2 - File Not Found
5 - Access Denied
13 - The data is invalid
50 - the request is not supported
87 - The parameter is incorrect

Glenn
_________________________
Actually I am a Rocket Scientist! \:D