Hello.
Name: OpenAsLibrary
This is a preliminary release, the scripts are to be merged as one and grossly enhanced during the week.
with the option of opening the folder instead of the file, if the control key is held down.
It will also open posix paths, which they don’t right now.
Usage:
You just put the cursor anywhere on the line which contains the hardcoded library path or selects it if you please, and the run this script. Then the library opens up in a new window.
Recommended shortcut keys (will work in all AppleScript Editors) is cmd opt O for opening the file, when the final version arrives you should put the open the folder option on cmd opt ctrl O
I will at some time not so distant in the future support both AppleMods and ScriptFactory’s loaders with this.
Enjoy
AppleScript Editor 2.x
-- The Idea and implementation and any faults is totally mine. © McUsr 2010 and put in the Public Domain.
-- The usually guarrantees about nothing what so ever applies, use it at your own risk.
-- Read the documentation.
-- You are not allowed to post this code elsewhere, but may of course refer to the post at macscripter.net.
” macscripter.net/viewtopic.php?pid=macscripter.net/viewtopic.php?pid=131743#p131743
(*
TERMS OF USE.
This applies only to posting code, as long as you don't post it, you are welcome to do
whatever you want to do with it without any further permission.
Except for the following: Selling the code as is, or removing copyright statmentents and the embedded link in the code (without the http:// part) from the code.
You must also state what you eventually have done with the original source. This obviously doesn't matter if you distribure AppleScript as read only. I do not require you to embed any properties helding copyright notice for the code.
Credit for having contributed to your product would in all cases be nice!
If you use this code as part of script of yours you are of course welcome to post that code with my code in it here at macscripter.net. If you then wish to post your code elsewhere after having uploaded it to MacScripter.net please email me and ask for permission.
The ideal situation is however that you then refer to your code by a link to MacScripter.net
The sole reason for this, is that it is so much better for all of us to have a centralized codebase which are updated, than having to roam the net to find any usable snippets. Which some of us probabaly originated in the first hand.
I'm picky about this. If I find you to have published parts of my code on any other site without previous permission, I'll do what I can to have the site remove the code, ban you, and sue you under the jurisdiction of AGDER LAGMANNSRETT of Norway. Those are the terms you silently agree too by using this code.
The above paragraphs are also valid if you violate any of my terms.
If you use this or have advantage of this code in a professional setting, where professional setting means that you use this code to earn money by keeping yourself more productive. Or if you as an employee share the resulting script with other coworkers, enhancing the productivity of your company, then a modest donation to MacScripter.net would be appreciated.
*)
-- © McUsr 2010 and put in Public Domain see: macscripter.net/viewtopic.php?pid=131743#p131743 for reference and terms of use.
set HYPHEN to "\""
set ESCAPE to "\\"
set {tids, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ""}
tell application "AppleScript Editor"
tell its document 1
activate
set startPoint to its character range of selection
copy startPoint to probe
check syntax
set its selection to characters ((item 1 of startPoint) as integer) thru ((item 2 of startPoint) as integer)
set {origStart, origEnd} to {(item 1 of probe), (item 2 of probe)}
set {selStart, selEnd} to {(item 1 of probe), (item 2 of probe)}
if (selStart - selEnd) is not equal to 0 then
set aFileName to its characters ((item 1 of startPoint) as integer) thru ((item 2 of startPoint) as integer) as Unicode text
set aFileName to my cleanFileName(aFileName)
if my couldOpenAsFile(aFileName) then
set AppleScript's text item delimiters to tids
return
end if
set selEnd to selStart + 1
else
set selEnd to selEnd + 1
end if
set fWardList to {}
set bWardList to {}
repeat
if character selStart is return then exit repeat
if character selStart is HYPHEN then set end of fWardList to selStart
set selStart to selStart - 1
if selStart is equal to 0 then exit repeat
end repeat
set fWardList to reverse of fWardList
repeat
if character selEnd is return then exit repeat
if character selEnd is HYPHEN then set end of bWardList to selEnd
set selEnd to selEnd + 1
end repeat
set hyphensList to fWardList & bWardList
repeat with i from 1 to ((count hyphensList) div 2) by 2
set aFileName to characters ((item i of hyphensList) as integer) thru ((item (i + 1) of hyphensList) as integer) as Unicode text
set aFileName to my cleanFileName(aFileName)
if my couldOpenAsFile(aFileName) then
set AppleScript's text item delimiters to tids
return
end if
end repeat
end tell
end tell
set AppleScript's text item delimiters to tids
on couldOpenAsFile(aFileName)
if (count aFileName) is not equal to 0 then
try
aFileName as alias
tell application "AppleScript Editor" to open aFileName
tell its document 1 to activate
return true
on error
return false
end try
end if
end couldOpenAsFile
on cleanFileName(aFileName)
-- removes everything that shouldn't be there when we try to create a fileName
repeat
if text item 1 of aFileName is my ESCAPE or text item 1 of aFileName is my HYPHEN then
set aFileName to text items 2 thru -1 of aFileName as Unicode text
else
exit repeat
end if
if (count aFileName) is not equal to 0 then exit repeat
end repeat
if (count aFileName) is not equal to 0 then
repeat
if text item -1 of aFileName is my ESCAPE or text item -1 of aFileName is my HYPHEN then
set aFileName to text items 1 thru -2 of aFileName as Unicode text
else
exit repeat
end if
if (count aFileName) is 0 then exit repeat
end repeat
end if
return aFileName
end cleanFileName
Script Debugger 4.5
-- The Idea and implementation and any faults is totally mine. © McUsr 2010 and put in the Public Domain.
-- The usually guarrantees about nothing what so ever applies, use it at your own risk.
-- Read the documentation.
-- You are not allowed to post this code elsewhere, but may of course refer to the post at macscripter.net.
” macscripter.net/viewtopic.php?pid=macscripter.net/viewtopic.php?pid=131743#p131743
(*
TERMS OF USE.
This applies only to posting code, as long as you don't post it, you are welcome to do
whatever you want to do with it without any further permission.
Except for the following: Selling the code as is, or removing copyright statmentents and the embedded link in the code (without the http:// part) from the code.
You must also state what you eventually have done with the original source. This obviously doesn't matter if you distribure AppleScript as read only. I do not require you to embed any properties helding copyright notice for the code.
Credit for having contributed to your product would in all cases be nice!
If you use this code as part of script of yours you are of course welcome to post that code with my code in it here at macscripter.net. If you then wish to post your code elsewhere after having uploaded it to MacScripter.net please email me and ask for permission.
The ideal situation is however that you then refer to your code by a link to MacScripter.net
The sole reason for this, is that it is so much better for all of us to have a centralized codebase which are updated, than having to roam the net to find any usable snippets. Which some of us probabaly originated in the first hand.
I'm picky about this. If I find you to have published parts of my code on any other site without previous permission, I'll do what I can to have the site remove the code, ban you, and sue you under the jurisdiction of AGDER LAGMANNSRETT of Norway. Those are the terms you silently agree too by using this code.
The above paragraphs are also valid if you violate any of my terms.
If you use this or have advantage of this code in a professional setting, where professional setting means that you use this code to earn money by keeping yourself more productive. Or if you as an employee share the resulting script with other coworkers, enhancing the productivity of your company, then a modest donation to MacScripter.net would be appreciated.
*)
-- © McUsr 2010 and put in Public Domain see: macscripter.net/viewtopic.php?pid=131743#p131743 for reference and terms of use.
property test : ""
set HYPHEN to "\""
set ESCAPE to "\\"
set {tids, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ""}
tell application "Script Debugger 4.5"
tell its script window 2
activate
set startPoint to character range of selection of its document
if item 1 of startPoint > item 2 of startPoint and item 2 of startPoint ≠0 then
set probe to item 2 of startPoint
set item 2 of startPoint to item 1 of startPoint
set item 1 of startPoint to probe
end if
copy startPoint to probe
set endPos to ((item 1 of startPoint) as integer) + ((item 2 of startPoint) as integer)
tell its document to compile
set test to script source of its document
if item 2 of probe is not 0 then
set item 2 of probe to (item 2 of probe) - (item 1 of probe) + 1
end if
set selection of its document to probe -- as list
set {origStart, origEnd} to {(item 1 of startPoint), (item 2 of startPoint)}
set {selStart, selEnd} to {(item 1 of probe), (item 2 of probe)}
if (selStart - selEnd) is not equal to 0 and selEnd is not equal to 0 then
set aFileName to (characters ((item 1 of startPoint) as integer) thru ((item 2 of startPoint) as integer) of test) as Unicode text
set aFileName to my cleanFileName(aFileName)
if my couldOpenAsFile(aFileName) then
set AppleScript's text item delimiters to tids
return
end if
set selEnd to selStart + 1
else
set selEnd to selStart + 1
end if
set fWardList to {}
set bWardList to {}
if character selStart of test is return then set selStart to selStart - 1
repeat
if character selStart of test is return then exit repeat
if character selStart of test is HYPHEN then set end of fWardList to selStart
set selStart to selStart - 1
if selStart is equal to 0 then exit repeat
end repeat
set fWardList to reverse of fWardList
repeat
if character selEnd of test is return then exit repeat
if character selEnd of test is HYPHEN then set end of bWardList to selEnd
set selEnd to selEnd + 1
end repeat
set hyphensList to fWardList & bWardList
repeat with i from 1 to ((count hyphensList) div 2) by 2
set aFileName to (characters ((item i of hyphensList) as integer) thru ((item (i + 1) of hyphensList) as integer) of test) as Unicode text
set aFileName to my cleanFileName(aFileName)
if my couldOpenAsFile(aFileName) then
set AppleScript's text item delimiters to tids
return
end if
end repeat
end tell
end tell
set AppleScript's text item delimiters to tids
on couldOpenAsFile(aFileName)
if (count aFileName) is not equal to 0 then
try
aFileName as alias
tell application "Script Debugger 4.5" to open aFileName
tell its document 1 to activate
return true
on error
return false
end try
end if
end couldOpenAsFile
on cleanFileName(aFileName)
-- removes everything that shouldn't be there when we try to create a fileName
repeat
if text item 1 of aFileName is my ESCAPE or text item 1 of aFileName is my HYPHEN then
set aFileName to text items 2 thru -1 of aFileName as Unicode text
else
exit repeat
end if
if (count aFileName) is not equal to 0 then exit repeat
end repeat
if (count aFileName) is not equal to 0 then
repeat
if text item -1 of aFileName is my ESCAPE or text item -1 of aFileName is my HYPHEN then
set aFileName to text items 1 thru -2 of aFileName as Unicode text
else
exit repeat
end if
if (count aFileName) is 0 then exit repeat
end repeat
end if
return aFileName
end cleanFileName
Smile
-- The Idea and implementation and any faults is totally mine. © McUsr 2010 and put in the Public Domain.
-- The usually guarrantees about nothing what so ever applies, use it at your own risk.
-- Read the documentation.
-- You are not allowed to post this code elsewhere, but may of course refer to the post at macscripter.net.
” macscripter.net/viewtopic.php?pid=macscripter.net/viewtopic.php?pid=131743#p131743
(*
TERMS OF USE.
This applies only to posting code, as long as you don't post it, you are welcome to do
whatever you want to do with it without any further permission.
Except for the following: Selling the code as is, or removing copyright statmentents and the embedded link in the code (without the http:// part) from the code.
You must also state what you eventually have done with the original source. This obviously doesn't matter if you distribure AppleScript as read only. I do not require you to embed any properties helding copyright notice for the code.
Credit for having contributed to your product would in all cases be nice!
If you use this code as part of script of yours you are of course welcome to post that code with my code in it here at macscripter.net. If you then wish to post your code elsewhere after having uploaded it to MacScripter.net please email me and ask for permission.
The ideal situation is however that you then refer to your code by a link to MacScripter.net
The sole reason for this, is that it is so much better for all of us to have a centralized codebase which are updated, than having to roam the net to find any usable snippets. Which some of us probabaly originated in the first hand.
I'm picky about this. If I find you to have published parts of my code on any other site without previous permission, I'll do what I can to have the site remove the code, ban you, and sue you under the jurisdiction of AGDER LAGMANNSRETT of Norway. Those are the terms you silently agree too by using this code.
The above paragraphs are also valid if you violate any of my terms.
If you use this or have advantage of this code in a professional setting, where professional setting means that you use this code to earn money by keeping yourself more productive. Or if you as an employee share the resulting script with other coworkers, enhancing the productivity of your company, then a modest donation to MacScripter.net would be appreciated.
*)
-- © McUsr 2010 and put in Public Domain see: macscripter.net/viewtopic.php?pid=131743#p131743 for reference and terms of use.
property test : ""
set HYPHEN to "\""
set ESCAPE to "\\"
set {tids, AppleScript's text item delimiters} to {AppleScript's text item delimiters, ""}
tell application "Smile"
tell its window 1
activate
set startPoint to selection
copy startPoint to probe
check syntax
set test to characters ((item 1 of startPoint) as integer) thru ((item 2 of startPoint) as integer) of its text
set selection to startPoint
set {origStart, origEnd} to {(item 1 of probe), (item 2 of probe)}
set {selStart, selEnd} to {(item 1 of probe), (item 2 of probe)}
if (selStart - selEnd) is not equal to 0 then
set aFileName to its characters ((item 1 of startPoint) as integer) thru ((item 2 of startPoint) as integer) as Unicode text
set aFileName to my cleanFileName(aFileName)
if my couldOpenAsFile(aFileName) then
set AppleScript's text item delimiters to tids
return
end if
set selEnd to selStart + 1
else
set selEnd to selEnd + 1
end if
set fWardList to {}
set bWardList to {}
repeat
if character selStart is return then exit repeat
if character selStart is HYPHEN then set end of fWardList to selStart
set selStart to selStart - 1
if selStart is equal to 0 then exit repeat
end repeat
set fWardList to reverse of fWardList
repeat
if character selEnd is return then exit repeat
if character selEnd is HYPHEN then set end of bWardList to selEnd
set selEnd to selEnd + 1
end repeat
set hyphensList to fWardList & bWardList
repeat with i from 1 to ((count hyphensList) div 2) by 2
set aFileName to characters ((item i of hyphensList) as integer) thru ((item (i + 1) of hyphensList) as integer) as Unicode text
set aFileName to my cleanFileName(aFileName)
if my couldOpenAsFile(aFileName) then
set AppleScript's text item delimiters to tids
return
end if
end repeat
end tell
end tell
set AppleScript's text item delimiters to tids
on couldOpenAsFile(aFileName)
if (count aFileName) is not equal to 0 then
try
aFileName as alias
tell application "Smile" to open aFileName
tell its document 1 to activate
return true
on error
return false
end try
end if
end couldOpenAsFile
on cleanFileName(aFileName)
-- removes everything that shouldn't be there when we try to create a fileName
repeat
if text item 1 of aFileName is my ESCAPE or text item 1 of aFileName is my HYPHEN then
set aFileName to text items 2 thru -1 of aFileName as Unicode text
else
exit repeat
end if
if (count aFileName) is not equal to 0 then exit repeat
end repeat
if (count aFileName) is not equal to 0 then
repeat
if text item -1 of aFileName is my ESCAPE or text item -1 of aFileName is my HYPHEN then
set aFileName to text items 1 thru -2 of aFileName as Unicode text
else
exit repeat
end if
if (count aFileName) is 0 then exit repeat
end repeat
end if
return aFileName
end cleanFileName