my goal is to have a library script of commands for applescript output (to display text, clear the window and close it), so that ii don’t have to paste code into every script that will use applescript output.
the problem i’m having is getting it to work. i saved the library as a script and an application, but neither way works. what in the blue blazes am i doing wrong? how do i get a script to send parameters to the library script and have the library script run right? i paired the thing just to get one to call the other, but it’s not working.
library script:
on bingy(somestuff)
say somestuff
end bingy
calling script:
tell application "library script"
bingy("charles")
end tell
If you saved your library as application (as you show in your example), your syntax is OK, but you must save the application as “stay-open” (simply check the related checkbox at saving-time).
If you save your library as a simple compiled script, this is the syntax:
set myLibrary to (load script alias "path:to:library.scpt")
tell myLibrary to bingy("charles")
NOTE that you can use the same code if your library is an application, since the “load script” command is able to load the applescript code embedded in your library-app.
Eg:
set myLibrary to (load script alias "path:to:library.app")
tell myLibrary to bingy("charles")
I am a newbie to this realm, and I’ve got a question along this thread.
I am also trying to build libraries for myself, but I would like mine to be portable.
By portable, I mean I would like to make it so that my AppleScript solution looks for “Library” folder under it’s current file location. How do I retrieve the current file path so I can basically do somethin like this?
set library_path to :AppleScript:utilities.scpt
You can guess the location of your script saved as application using the command “path to me”, or to common locations in a computer using “path to x” (for “x”, see the entry in the Standard Additions dictionary).