Subfunction already exist. See Err() - Prints an error message on screen and writes the error into the error log , which uses an embedded "TranslateCOMError()" UDF to translate COM error numbers to Win32 error numbers. The included subfunction is build as a textstring, then EXECUTEd.The relevant code snippet is below:
function err()
$errorcode=@ERROR
$errortext=@SERROR
If $errorcode<0
$errorsub=$errorsub+'Function TranslateCOMError($lErr)'+@CRLF
$errorsub=$errorsub+'If $lErr<0 $lErr=VAL("&"+Right(DecToHex($lErr),4)) EndIf'+@CRLF
$errorsub=$errorsub+'exit $lErr'+@CRLF
$errorsub=$errorsub+'Endfunction'
$errortext=execute($errorsub)
$errorcode=TranslateCOMError($errorcode)
$errorcode=@ERROR
$errortext=@SERROR
EndIf
? ''+$errorcode+' - '+$errortext
endfunction



I don't like #3 as it might result in two different variable swith the same spelling but capitalization differences. This would make code harder to read as one will need to remember the differences between the two or more spellings.

[ 10. October 2003, 14:53: Message edited by: sealeopard ]
_________________________
There are two types of vessels, submarines and targets.