Jump to content

Program termination: Difference between revisions

→‎{{header|AppleScript}}: Corrected existing entry.
(add task to ARM64 assembly Raspberry Pi)
(→‎{{header|AppleScript}}: Corrected existing entry.)
Line 151:
 
=={{header|AppleScript}}==
Contrary to what was stated in the previous entry here, AppleScript's "User canceled." error (number -128) stops the script execution immediately and does ''not'' cause a dialog to appear. (There may have been dialog at some point in the past owing to a bug in one of the earlier systems.) However, the error can be trapped if required and a specified action taken.
AppleScript doesn't include a built-in command for immediate script termination. The <code>return</code> command can be used to exit the main run handler, but will not force termination of the entire script from another handler/function.
<lang AppleScript>on run
If problem then return
end run</lang>
It's possible to simulate an immediate program termination from within any handler by throwing a user error, but this will force a modal dialog (AppleScript Error) to appear announcing the error. Such a dialog cannot be bypassed, and the script immediately quits upon user acknowledgement.
<lang AppleScript>on run
f()
display dialog "This message will never be displayed."
end run
 
If the script's running as an applet, the applet will quit as soon as the script stops — unless it's a stay-open applet, in which case it will be necessary to use a <code>quit</code> command instead of, or immediately before, the error command.
on f()
 
error
The memory used belongs to the application running the script and is reclaimed automatically.
end f</lang>
 
Memory is automatically managed and reclaimed by AppleScript.
<lang applescript> if (someCondition) then error number -128</lang>
 
In a stay-open applet:
 
<lang applescript>on idle -- A stay-open applet's 'idle' handler is called periodically while the applet remains open.
-- Some code, including:
if (someCondition) then
quit -- Quit the applet when the script stops executing.
error number -128 -- Stop executing the script. (Not necessary on recent systems.)
end if
 
return 10 -- Number of seconds to the next call of this handler if the applet's still open.
end runidle</lang>
 
=={{header|ARM Assembly}}==
557

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.