Thursday, November 23, 2017

#1 2017-10-31 03:27:53 pm

daBee
Member
Registered: 2010-02-09
Posts: 81

BBEdit Word Change

Hi folks.

I'm wanting to write a script that tests this for "true" or "false" and inverts that value:

BBEdit
  Window 1
    Current line (focus of cursor)

Is there a way of getting contents of the current focus line, testing it for a value, then changing that value?

I hope this description is clear. 

Cheers


Filed under: BBedit, current line

Offline

 

#2 2017-10-31 09:11:25 pm

Marc Anthony
Member
From:: Dallas, TX
Registered: 2006-04-27
Posts: 771

Re: BBEdit Word Change

Hi. It sounds like you're actually just asking how to do a find/replace. Assuming there's no more than one of those strings in any given line, something like this could work:

Applescript:

tell application "BBEdit"'s window 1
   tell line (selection's startLine)
       if contents contains "true" then
           replace "true" using "false" searching in it options {showing results:0, returning results:1}
       else
           replace "false" using "true" searching in it options {showing results:0, returning results:1}
       end if
   end tell
end tell

Offline

 

#3 2017-11-04 05:34:14 pm

daBee
Member
Registered: 2010-02-09
Posts: 81

Re: BBEdit Word Change

Brilliant.  Thank you.  I like the "it" object.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)