Name
GetLastError -- get error code for the last command
Synopsis
code = GetLastError()
Function
This function queries Hollywood's internal error flag and returns the result. This flag is zero if the last command executed was successful. If the command failed, an error code which is not zero will be returned. This error code can than be used to query Hollywood for a name string that describes the error occurred. (use GetErrorName() then)

Important note: Hollywood's internal error flag will be reset to zero before a command is called. Therefore the error code you will get when you call GetLastError() is the error code of the function that was called before GetLastError().

Important note #2: This function is only useful if the automatical error handler is disabled. If it is enabled (which is the default), the error handler will break your script immediately when an error occurs. So your script will never reach a GetLastError() call if an error occurred and the automatic error handler is enabled. Therefore you will have to call ExitOnError() with False as the flag to disable Hollywood's error handler.

See Error codes for a list of all error codes defined by Hollywood.

Inputs
none

Results
code
non-zero if an error occurred, zero for success
Example
ExitOnError(FALSE)       ; disable automatic error handler
LoadBGPic(1,"blablabla") ; this command will fail!
code=GetLastError()
If code<>0
  err$=GetErrorName(code)
  SystemRequest("An error occurred!",err$,"OK")
  End
EndIf
The above code shows how to handle the error that LoadBGPic() will produce. It is important that there is no further command between the LoadBGPic() and the GetLastError(). If there would be another command, it would trash the error results of LoadBGPic().

Show TOC