I'd rather do ancode:
$rc=WRITEVALUE(...)
if @ERROR
$err=@ERROR
endif
This way you will receive the correct error code for the last failed write. It does imply that previous write might have failed with the same error code. The advbantage is that e.g. an error code of 2 can be translated to the correct @SERROR message if you put an 'exit $err' at the end of your function.
I am modifying my UDfs to return proper errro codes by using the following syntax where applicable:
code:
function dummy($a)
;doding stuff
$dummy='return value'
exit @ERROR
endfunction
If possible I try to copy the KiXtart syntax by returning '0' for successful UDFs and the appropriate error code for failed UDFs. I can then evaluate @ERROR/@SERROR outside the UDF.
_________________________
There are two types of vessels, submarines and targets.