You have to pass the error strings into the UDF, otherwise the errors might not get captured correctly, thus
Code:

; example
use x: '\\server\nonavailable_share'
$rc = errorlog(@error,@serror)
; end example
function ErrorLog($error, $serror, optional $ErrorMsg)
DIM $LogFile,$LogError,$AltLogFile,$ErrorString
$ErrorString = "Error "+$error+", "+$serror+", "+$ErrorMsg+", "+@WKSTA+", "+@USERID+", "+@DATE+", "+@TIME+", "+@CRLF
$LogFile = "\\server\SoftwarePushes\sms\logging\"+@MDayNo+"_"+@MonthNo+"_"+@Year+".log"
$AltLogFile = "\\server\SoftwarePushes\sms\logging\"+@MDayNo+"_"+@MonthNo+"_"+@Year+"-@WKSTA.log"
$LogError = OPEN (5,$LogFile,5)

If $LogError=0
$ = WRITELINE(5,$ErrorString)
$ = CLOSE(5)
Else
$ = OPEN (6,$AltLogFile,5)
$ = WRITELINE(6,$ErrorString)
$ = CLOSE (6)
EndIf

endfunction


You're also not providing a facility to not log error code 0 = success. You're also not handling a potential non-opening og file handle 6. I highly recommend to use FREEFILEHANDLE to assign file handles. The main log file might already be in use if multiple computers report errors, thus I'd rcommend to write to the alternative log file right away to prevent potential ocking issues. You're also not providing an return code for the UDF. Please read 'How to write UDFs' in the FAQ Forum.
_________________________
There are two types of vessels, submarines and targets.