Control Structures
These are examples of control structures. You may also be interested in:

 Conditional structures
 Exceptions
 Flow-control structures
 Loops

This task is to give an example of an exception handling routine
and to "throw" a new exception.



Related task

   Exceptions Through Nested Calls


-- parent script "ErrorHandler"
 
on alertHook (me, errorType, errorMessage, alertType)
  if alertType=#alert then return 0 -- ignore programmatic alerts
 
  -- log error in file "error.log"
  fn = _movie.path&"error.log"
  fp = xtra("fileIO").new()
  fp.openFile(fn, 2)
  if fp.status() = -37 then
    fp.createFile(fn)
    fp.openFile(fn, 2)
  end if
  fp.setPosition(fp.getLength())
  fp.writeString(_system.date() && _system.time() && errorType & ": " & errorMessage & RETURN)
  fp.closeFile()
 
  return 1 -- continues movie playback, no error dialog
end