Fuse,
You can get the effect you desire by using a UDF to set the error. I used this to print out all the available text error message:
code:
$=redirectoutput("errors.txt")for $i = 0 to 99999
SetError($i)
if "@SERROR" = ""
if $blank else $blank=$i endif
else
if $blank
? " $blank to " $i-1 " have no message" ? ?
$Blank=0
endif
"@ERROR: @SERROR" ?
endif
next
if $blank
? " $blank to " $i " have no message" ? ?
endif
$=redirectoutput("")
return
function SetError($i)
exit $i
endfunction
You could then do something like this in your code:
code:
; Initialisation area
$ERROR_SUCCESS=0
$ERROR_FILE_NOT_FOUND=2
$ERROR_ACCESS_DENIED=5$DEBUG=1
$ERRORCHECK=2
$PRODUCTION=0
; Set CODE_STATE to indicate the current state of your code
$CODE_STATE=$DEBUG | $ERRORCHECK
; Initialise @ERROR to OK.
SetError($ERROR_SUCCESS)
...
md "c:\foo\bar"
if $CODE_STATE & $ERRORCHECK SetError($ERROR_ACCESS_DENIED) endif
if @ERROR
"Error @ERROR: @SERROR encountered making directory" ?
if ($CODE_STATE & DEBUG) AND ($CODE_STATE & $ERRORCHECK)
"DEBUG: Forced errors are ON"
endif
endif
return
FUNCTION SetError($ErrorNumber)
exit $ErrorNumber
ENDFUNCTION
------------------
Richard Howarth