Skip to main content

Popularity Report

Total Popularity Score: 0

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Rank

Bookmark History

Saved by 4 people (-2 private), first by anonymouse user on 2007-01-03


Public Sticky notes

tell application "Finder" set theSelection to selection set n to number of items in theSelection -echo "number of items selected: " & n repeat with i from 1 to n -echo "item " & i & " is " & (item i of theSelection as alias) end repeat end tell

Highlighted by kamiura

Features

  • Interactive execution of AppleScript commands
  • Handles multi-line commands (e.g. 'tell') by going into a mode - current mode is indicated by the prompt
  • Subroutines (starting with "on" or "to") and script objects (starting with "script") are persistent and thus are available for use in any subsequent interactive command
  • Can be used as the " shebang" interpreter for stand-alone scripts that run non-interactively. The "shebang" line for such scripts would be: #!/usr/bin/env ash
    (assuming that the 'ash' script is in your PATH) You can also execute files of AppleScript commands by supplying the filenames on the command-line when you invoke 'ash'.
  • The "-source" command can be used to execute the commands in a file (like the 'source' command in 'tcsh' and 'bash') This is especially useful for bringing in subroutine definitions.
  • The "-echo" command can be used to output the values of AppleScript expressions - this is especially useful for debugging. For example:
        tell application "Finder"
            set theSelection to selection
            set n to number of items in theSelection
            -echo "number of items selected: " & n
            repeat with i from 1 to n
                -echo "item " & i & " is " & (item i of theSelection as alias)
            end repeat
        end tell
    
  • The "-abbrev" command allows creation of abbreviations for commonly used phrases
  • The "-show" command displays the current AppleScript
  • The "-editor" command sends the current AppleScript to Apple's "Script Editor"
  • The "-rerun" command reruns the most recently executed AppleScript
  • The "-batch" command allows a bunch of AppleScript commands to be batched up for later execution
  • The "-read" command can be used to read from the keyboard into an AppleScript variable.
  • The "-cd", "-pwd", "-ls" commands operate like the standard shell commands.
  • The "-!" escape can be used to run an arbitrary Unix command.
  • The "-createMan" command generates a 'man page' file for 'ash'.
  • You can use the "-oneoff" command-line option to have 'ash' automatically exit after running one (interactively supplied) AppleScript command.
  • You can enable a "trace facility" for the execution of your AppleScripts via the "-trace" option. In trace mode, the execution pauses after each AppleScript statement and displays the result from the previously executed statement.
  • More detailed usage information is available via the "-help" command.

Highlighted by joshvh