Re: Upgrading and Apple Scripts

2017-09-19 Thread Christian Boyce
In my experience, the only AppleScript thing that changed between 9 and 11 had 
to do with the target of the search and replace. This was a problem for me in 
moving from 10 to 11. For example:

tell application "BBEdit 10"
set the_Text to the selection
set find_string to "this"
set replace_string to "that"
tell the_Text
replace find_string using replace_string options {starting at 
top:false, wrap around:false, backwards:false, case sensitive:false, match 
words:false, extend selection:false}
end tell
end tell

If I have a document full of the word "this" and I select part of the document, 
and I run the script, it changes only the part that is selected. That is what I 
expected since I said "tell the_Text." The AppleScript dictionary for BBEdit 10 
documents that--

searching inoptionalanything   where to 
replace the string (defaults to the tell-target of the event)


But... if I run the same script against the same text file in BBEdit 11.5.3, it 
changes every instance of "this" starting in the_Text but also continuing to 
the end of the document.

The extend selection option is supposed to be false if omitted, but whether I 
omit it or specify "false" the replacing continues to the end of the document.

I noticed this because one of my customers uses a script that is applied to a 
selected range of text, but they saw it make changes all the way to the end of 
the document. It worked for years but broke in version 11.x. They are on 11.5.3 
and so am I, downloaded directly from barebones.com .

***

I contacted Bare Bones tech support about this and received this message, which 
explained what was going on:

> First, please note that per BBEdit 11's scripting dictionary, many of the 
> options you mention from BBEdit 10 are no longer applicable.
> 
> In addition, the behavior of the 'replace' command is now consistent with 
> that of the GUI "Replace All" command, in that both commands replace _all 
> actual_ instances present in the document irrespective of the insertion 
> point's position or the active selection range (unless explicitly targeted).
> 
> Next, if you want a script to operate upon the selected text only, then you 
> must explicitly specify that text as the target of the operation, e.g.
> 
> tell application "BBEdit"
>set find_string to "this"
>set replace_string to "that"
>   
>replace find_string using replace_string searching in selection of text 
> window 1
> end tell
> 
> and this same construction should also work with BBEdit 10.


***

There may be other differences between 9 and the current version but for sure, 
watch out for "tell the selection" because it does not do what it used to. It's 
not as if it's a problem. You just have to change the way your write the script.

c
> On Sep 19, 2017, at 12:33 PM, Chuck Dingee  > wrote:
> 
> I have been using BBEdit for many years, and it has been quite a few since I 
> have upgraded. I am using version 9.6.3 (ancient, I know). I love it, and I 
> figure if it ain't broke don't fix it. But I am thinking of upgrading now and 
> want to make sure my old Apple Scripts will work. (Obviously I would need to 
> tweak them, but do I need to start from scratch?)
> Thanks!

-- 
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: Upgrading and Apple Scripts

2017-09-19 Thread Oliver Boermans
I say give it a shot.
Keep a copy of BBEdit 9, make sure your Application Support/bbedit folder
is backed-up and give the demo a spin.

There may be breaking changes, but I expect they are relatively few.

On 20 September 2017 at 05:03, Chuck Dingee  wrote:

> I have been using BBEdit for many years, and it has been quite a few since
> I have upgraded. I am using version 9.6.3 (ancient, I know). I love it, and
> I figure if it ain't broke don't fix it. But I am thinking of upgrading now
> and want to make sure my old Apple Scripts will work. (Obviously I would
> need to tweak them, but do I need to start from scratch?)
> Thanks!
>
> --
> 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.
>

-- 
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.


Upgrading and Apple Scripts

2017-09-19 Thread Chuck Dingee
I have been using BBEdit for many years, and it has been quite a few since I 
have upgraded. I am using version 9.6.3 (ancient, I know). I love it, and I 
figure if it ain't broke don't fix it. But I am thinking of upgrading now and 
want to make sure my old Apple Scripts will work. (Obviously I would need to 
tweak them, but do I need to start from scratch?)
Thanks!

-- 
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.