Re: Open your files in your editor of choice (BBEdit version :)

2018-07-24 Thread Christopher Stone
On 07/24/2018, at 17:35, @lbutlr mailto:krem...@kreme.com>> 
wrote:
> I have a script that does, I think, the same thing:


Hey Lewis,

It does.

> Is there a reason to return an error?

It's polite to provide at least basic error-handling in publicly posted 
scripts, although I'm guilty of not always doing so.  :)

I'm somewhat lax about error-handlers in AppleScripts I run on my own machine, 
because I nearly always run them from FastScripts – which has it's own error 
wrapper and error dialog.

BBEdit's script menu has a similar mechanism.

Giving a script more specific error messages helps unsophisticated users and 
can sometimes keep me from having too many "Huh!!??" moments.

My most generic error handler:



try

1 / 0 -- generate an error for testing.

on error e number n
set e to e & return & return & "Num: " & n
if n ≠ -128 then
try
tell application (path to frontmost application as text) to set 
ddButton to button returned of ¬
(display dialog e with title "ERROR!" buttons {"Copy Error 
Message", "Cancel", "OK"} ¬
default button "OK" giving up after 30)
if ddButton = "Copy Error Message" then set the clipboard to e
end try
end if
end try



--
Take Care,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: Open your files in your editor of choice (BBEdit version :)

2018-07-24 Thread @lbutlr
On 24 Jul 2018, at 14:26, Christopher Stone  wrote:
> 
> set appID to "com.apple.TextEdit"
> 
> tell application "Finder"
> set finderSelectionList to selection as alias list
> if length of finderSelectionList = 0 then error "No files were selected 
> in the Finder!"
> 
> open finderSelectionList using application file id appID
> 
> end tell

I have a script that does, I think, the same thing:


set appID to “com.barebones.BBEdit"
tell application "Finder"
set myList to selection as alias list
if length of myList > 0 then
open myList using application file id appID
end if
end tell

Is there a reason to return an error?

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: Open your files in your editor of choice (BBEdit version :)

2018-07-24 Thread Jean-Christophe Helary
Thank you Chris :)

Jean-Christophe 

> On Jul 25, 2018, at 5:26, Christopher Stone  
> wrote:
> 
> On 07/22/2018, at 04:20, Jean-Christophe Helary  > wrote:
>> Some trivial AppleScript almost 100% provided by Chris Stone :)
> 
> 
> Hey Jean-Christophe,
> 
> If you really want a one-size-fits-all approach then this is the way to go:
> 
> 
> # Auth: Christopher Stone
> # dCre: 2018/07/24 15:19
> # dMod: 2018/07/24 15:19 
> # Appl: Finder and any given application.
> # Task: Open the Finder selection with a given app's bundle identifier.
> # Libs: None
> # Osax: None
> # Tags: @ccstone, @Applescript, @Script, @Finder, @Open, @Finder, @Selection, 
> @Bundle, @Identifier, @ID
> 
> 
> # Bundle Identifier of the app you want to open the selected files.
> set appID to "com.apple.TextEdit"
> 
> tell application "Finder"
> set finderSelectionList to selection as alias list
> if length of finderSelectionList = 0 then error "No files were selected 
> in the Finder!"
> 
> open finderSelectionList using application file id appID
> 
> end tell
> 
> 
> 
> It should work with just about any application.
> 
> --
> Take Care,
> Chris
> 
> 
> -- 
> This is the BBEdit Talk public discussion group. If you have a 
> feature request or would like to report a problem, please email
> "supp...@barebones.com" rather than posting to the group.
> Follow @bbedit on Twitter:  >
> --- 
> You received this message because you are subscribed to the Google Groups 
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to bbedit+unsubscr...@googlegroups.com 
> .
> To post to this group, send email to bbedit@googlegroups.com 
> .
> Visit this group at https://groups.google.com/group/bbedit 
> .

Jean-Christophe Helary
---
http://mac4translators.blogspot.com @brandelune


-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Re: Open your files in your editor of choice (BBEdit version :)

2018-07-24 Thread Christopher Stone
On 07/22/2018, at 04:20, Jean-Christophe Helary mailto:brandel...@gmail.com>> wrote:
> Some trivial AppleScript almost 100% provided by Chris Stone :)


Hey Jean-Christophe,

If you really want a one-size-fits-all approach then this is the way to go:


# Auth: Christopher Stone
# dCre: 2018/07/24 15:19
# dMod: 2018/07/24 15:19 
# Appl: Finder and any given application.
# Task: Open the Finder selection with a given app's bundle identifier.
# Libs: None
# Osax: None
# Tags: @ccstone, @Applescript, @Script, @Finder, @Open, @Finder, @Selection, 
@Bundle, @Identifier, @ID


# Bundle Identifier of the app you want to open the selected files.
set appID to "com.apple.TextEdit"

tell application "Finder"
set finderSelectionList to selection as alias list
if length of finderSelectionList = 0 then error "No files were selected in 
the Finder!"

open finderSelectionList using application file id appID

end tell



It should work with just about any application.

--
Take Care,
Chris

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.


Open your files in your editor of choice (BBEdit version :)

2018-07-22 Thread Jean-Christophe Helary
Some trivial AppleScript almost 100% provided by Chris Stone :)

https://mac4translators.blogspot.com/2018/07/open-file-in-your-editor-of-choice.html


Jean-Christophe Helary
---
http://mac4translators.blogspot.com @brandelune

-- 
This is the BBEdit Talk public discussion group. If you have a 
feature request or would like to report a problem, please email
"supp...@barebones.com" rather than posting to the group.
Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To post to this group, send email to bbedit@googlegroups.com.
Visit this group at https://groups.google.com/group/bbedit.