loading scripts from a relative path?
loading scripts from a relative path?
- Subject: loading scripts from a relative path?
- From: Alex Hall <email@hidden>
- Date: Sun, 26 May 2013 16:51:15 -0400
Hi all,
I'm still working on my collection of scripts that speak information to the user, again intended mostly for VO users. Since I plan to distribute these, I need my load script functions (each speaking script uses two "libraries") to be relative. I know there is the usual way with Finder (tell Finder to get parent of (path to me)), but since each script will execute completely each time the user invokes it, not stay open, that is two loads and two calls to Finder each time the user wants, say, the time, to say nothing of any shell commands the script does.
So, I guess I have two questions:
1. If I use Finder, is there really much of a performance hit, or am I worried about nothing?
2. If Finder is a bad idea to use that often, how else could I get the relative path to the script?
Yes, I can write a load function that grabs "path to me", breaks it up by colons, then gives me all but the last (thereby giving me "path to me" without the script name) but that's hardly reusable. I'll do that if I have to, and leave that handler in every script, but a native solution would be cleaner and, I suspect, a bit faster.
To be clear, say "wifi status.scpt" is invoked. Whichever folder it is in will have utilities.scpt and getResourceInfo.scpt, both of which wifi status.scpt loads before it goes about getting the wifi status and then speaking it aloud. In sudocode, I'd do this:
import "./utilities.scpt"
import "./getResourceInfo.scpt"
I hope I've explained this well enough. Thanks for any help.
Have a great day,
Alex (msg sent from Mac Mini)
email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden