Re: Script Starter Templates
Re: Script Starter Templates
- Subject: Re: Script Starter Templates
- From: Iurista GmbH <email@hidden>
- Date: Mon, 11 Jan 2016 20:47:52 +0100
Am 24.12.2015 um 13.47 schrieb S. J. Cunningham:
>
>> snip...snip...snip..
>
> You're right, of course. I think I'll move the handlers from my template into a run-time library. That means I'll have to find some way to keep the script relocatable, however. I don't see an easy way to do that. If I include the library in the folder with the script, I'm back to changing multiple copies of the included handlers. I guess if I store the library in /Library/MyScriptLibrary or some such I'd only have a copy per machine to change.
>
> Steve
Hi Steve
As you, I'm also still on 10.6.8, with no "official" place for Libraries.
So I've made a script "LibPlaceSetter" defining that place, which gives me the free choice of moving things around to my liking. Maybe that helps you...
--------------------------------------------------
# FILENAME LibPlaceSetter
# AUTHOR Rudolf Durrer
# CREATED ON 31.01.15
# COPYRIGHT ©rod, 2015. All rights reserved.
# MODIFICATIONS snip...snip...snip...
-------------------------------------------------- MAIN
# Delete old & create new Main Definition File
set Maindef to "_MainDefs2.scpt" --or, instead of Prefix "_", one may use "§"
try
tell application "Finder" to delete alias ((path to "pref" as text) & Maindef)
end try
my newFile(Maindef)
-------------------------------------------------- HANDLER
#Note: for this script, I've choosen an Folder hierarchy "Handlers & Libraries:Libraries:" in the folder where this script is located. This makes the folder containing this script freely movable. But the path provided by def3 here under can also be choosen freely according to someone's mood
# def3 is only because my script contains more defs
on newFile(Maindef)
tell application "Finder" to set myContainer to container of (path to me) as alias as text
set Header to ¬
"-------------------------------------------------------------------
# FILENAME _MainDefs2
# KIND: AS LIBRARY
# PROJECT: ASS (AppleScript Support)
# FUNCTION: Enthält die grundsätzlichen Definitionen für ASS
# DEPENDENCIES: None
# AUTHOR Rudolf Durrer
# CREATED ON 21.12.15
# COPYRIGHT ©rod 2015. All rights reserved.
-------------------------------------------------------------------
"
set NameProp to "property myName : \"§MainDefs2\""
set def3 to ¬
"on _asl()" & return & ¬
"return " & "\"" & myContainer & "Handlers & Libraries:Libraries:" & "\"" & return & ¬
"end _asl" & return & return
set Definitions to def3 --def1 & def2 & def3 & def4 & def5 & def6 & def7
set myText to Header & return & return & NameProp & return & return & Definitions
set InitText to quoted form of myText
set applescriptPath to ((path to "pref" as text) & Maindef)
do shell script ("echo " & InitText & " | osacompile -o " & quoted form of POSIX path of applescriptPath)
tell application "Finder" to repeat until alias ((path to "pref" as text) & Maindef)
delay 0.1
end repeat
end newFile
-------------------------------------------------- END
Now, include the following code at start of your scripts:
-------------------------------------------------- Get Lib Place
# Scriptloader Main Definitions
set MDF to (load script alias (POSIX file (do shell script "find " & POSIX path of (path to "pref") & " -name _M*")))
#Find the library place
set ASL to MDF's _asl() as alias --the path where the libraries are
#or load a library file
set myHandler to (load script alias (MDF's _asl() & "YOUR SCRIPT NAME HERE.scpt"))'s readKey
-->«handler readKey» of library "PlistAccessLib.scpt"
-------------------------------------------------- END
And if you save this code as an applet in the same Folder as the script "LibPlaceSetter", you can add it to your login items and have a handy "Starter" each time you log in, so your path to your Library folder will always be up-to-date
-------------------------------------------------- Start LibPlaceSetter
run script alias ((POSIX file (POSIX path of ((path to me as text) & "::")) as text) & "LibPlaceSetter.scpt")
display dialog "Hinweis" & return & return & return & "Der AppleScript Support wurde erfolgreich eingerichtet" & return & return & return buttons {"Diese Meldung verschwindet selber"} giving up after 3
-------------------------------------------------- END
Rudolf
PS: Sorry for some german comments & text
_______________________________________________
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