Re: path to script file in script's folder
Re: path to script file in script's folder
- Subject: Re: path to script file in script's folder
- From: Mitchell L Model <email@hidden>
- Date: Tue, 28 Jun 2016 12:12:48 -0400
> On Jun 27, 2016, at 8:24 PM, email@hidden wrote:
>
> Message: 8
> Date: Tue, 28 Jun 2016 09:43:47 +1000
> From: Shane Stanley <email@hidden>
>
>>
>> Two scripts, main.scpt and support.scpt, are in the same folder. What is the best way to refer to support.scpt in a “load script file”?
>
> Put it somewhere else. Seriously.
>
:-)
This is an issue of a delivering a group of interrelated scripts to users. “Support.scpt” is intentionally named. (I did neglect to say I wanted to use Support.scpt in main.scpt.) I have no control over user’s environment, and the scripts don’t belong in Script Libraries because they are “application specific”. I think users would almost always be reluctant to add things to Script Libraries unless they came from very authoritative sources. Or, as I saw someone do recently, at least put the script in a domain-specific subfolder of Script Libraries such as org.software-concepts, but even that is a little too heavy-duty for what I am trying to do.
>
>
> ------------------------------
>
> Message: 9
> Date: Mon, 27 Jun 2016 19:24:16 -0500
> From: Christopher Stone <email@hidden>
>
> For what reason are these in the same folder?
as above — for delivering several scripts that work together — modularization without requiring users to install scripts in Script Libraries. Also because there may be several scripts in the folder that use Support.scpt, which case Support.scpt starts to look like it belongs in Script Libraries, but it doesn’t because it is specific to the other scripts in the folder and not general enough to warrant going in the user’s library. Besides, putting it there may cause terminology conflicts with more significant and generally useful Script Libraries.
One kind of case would be where I have several scripts that all need some rather specific handlers.
>
>> What is the best way to refer to support.scpt in a “load script file”?
>
> Why are you using load script instead of use script?
It is my impression from my reading and limited experience that “use” brings in scripts from /Library/Script Libraries, or ~/Library/Script Libraries, or in the specific case of “scripting additions” from some magical place. Otherwise, “use" is used to bring in frameworks. Do I have that right? So “load script file” allows loading from someplace other than Script Libraries — been doing that for ages, using my own library folder stored in some random place.
Another reason not to ask users to put a file like Support.scpt in Script Libraries is because it is not sufficiently elegant or debugged for general purpose use, but works well enough in support of the other scripts in the same folder.
Or, just standard program design, breaking up a program into smaller pieces, for organization, to have one script object per file (like Java classes), to have globals or properties that should be accessible to some of the code but not the rest, etc.
I guess the situation I am facing lies in a middle ground between distributing a script that relies on one worth asking the user to put in Script Libraries, and my own personal scripts that rely on scripts I keep in my own folders of library-type scripts.
>
> With a saved script you can always use:
>
> set supportScriptPath to (path to me as text) & ":support.scpt”
and then “load script file supportScriptPath”
>
> But there are better methods these days.
>
like what? I guess that was my basic question, other than getting the “path to me as text” exactly right.
_______________________________________________
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