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

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:

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

Brilliant. Thank you. I like the “it” object.