Modulinos: Difference between revisions

Added AppleScript.
(Added AppleScript.)
Line 24:
print(‘Life means ’life:meaning_of_life()‘.’)
print(‘Death means nothing.’)</lang>
 
=={{header|AppleScript}}==
 
AppleScript's equivalent of a main() function is a <tt>run</tt> handler, which can be either implicit or explicit:
 
<lang applescript>display dialog "Hello"</lang>
or
<lang applescript>on run
display dialog "Hello"
end run</lang>
 
A <tt>run</tt> handler's only executed when the script containing it is explicity ''run'', either from another script or application or as an application in its own right. It's not executed when a script's simply loaded as a library, although it can subsequently be so in the unlikely event of this being desirable. Scripts saved as applications aren't recognised by the "Libraries" system introduced in Mac OS X 10.9, but can be loaded and/or run using the older <tt>load script</tt> and <tt>run script</tt> commands. Script code can tell if it's running in its own application or being executed by an external agent by comparing its file path with that of the agent:
 
<lang applescript>on run
if ((path to me) = (path to current application)) then
display dialog "I'm running in my own application."
else
display dialog "I'm being run from another script or application."
end if
end run</lang>
 
=={{header|Arturo}}==
557

edits