2.6. AppleScript support

AppleScript can be great for automating tasks, gluing applications together, or for extending the functionality of existing applications. The current edition of MeVisLab for macOS provides experimental support for AppleScript. To display the available scripting facilities open the scripting dictionary using the Script Editor’s Open Dictionary... menu item (Figure 2.6, “MeVisLab scripting dictionary displayed in Script Editor”).

Figure 2.6. MeVisLab scripting dictionary displayed in Script Editor

MeVisLab scripting dictionary displayed in Script Editor

For instance

tell application "Microsoft Excel"
  tell active sheet of active workbook
    --set paramsList to value of used range
    set paramsList to formula of used range
    repeat with currentParams in paramsList
      tell application "MeVisLab"
        set theResult to run macro "AppleScriptTest" with parameters currentParams
      end tell
    end repeat
  end tell
end tell

will pass each row of contents of the current worksheet of a Microsoft Excel workbook as parameters to the function that has been assigned to the consoleCommand of the MeVisLab macro AppleScriptTest. Whereas

tell application "MeVisLab"
  repeat with incrementalValue from 1 to 10 by 2
    set theResult to run macro "AppleScriptTest" with parameters {"Hello", incrementalValue}
  end repeat
end tell

will repeatedly run the macro AppleScriptTest by calling its consoleCommand with the given parameters. The line

set mlabVersion to version of application "MeVisLab"

will assign the current version of MeVisLab to the variable mlabVersion.