BBEdit Applescrtipt


I know not a lot about applescript - i feel more at home with Java but i wrote a script a while ago with the help of a work colleague which said this:

tell BBedit

save document 1

end tell

Now that BBEdit has a new Interface i need to modufy the script so that the document i am editing is saved and not the first document in BBEdits list.

What i want to know is where the function definition is for “save” - or API for save.

I looked in BBEdit dictionary - i figured out the method call i was interedted in - but i couldnt figure out how to create a new save script.


save document 1

to change to

save active document of text windows



my BBEdit dictionary tells me the save statement has this options:

save: Save a window’s contents in text format. (from Standard Suite)
	save reference  -- window to save
 		[to alias] -- file in which to save the window’s contents
 		[saving as stationery boolean] -- save the file as stationery? (By Default, false.)
 		[add to recent list boolean] -- add to the application's recent file list? (By Default, true.)
 		[add to favorites list boolean] -- add to the application's favorite file list? (By Default, true.)

The window class has the following properties:

Class window: an open window
Plural form:
	text by numeric index
Super classes:
Sub classes:
	about_window, differences window, disk browser window, FTP browser window, group window, palette, movie window, preferences_window, picture window, QuickTime window, results browser, text window
	properties record  -- (inherited from the “item” class) all of this object’s properties
	ID integer  [r/o]  -- (inherited from the “item” class) object’s unique id
	container reference  [r/o]  -- (inherited from the “item” class) object’s container (if any)
	bounds bounding rectangle  -- the boundary rectangle for the window
	closeable boolean  [r/o]  -- Does the window have a close box?
	index integer  -- the number of the window
	modal boolean  [r/o]  -- Is the window modal?
	file alias  [r/o]  -- the disk file associated with this window, if any
	modified boolean  [r/o]  -- Has the window been modified since the last save?
	name international text  -- the title of the window
	position point  -- upper left coordinates of the window
	resizable boolean  [r/o]  -- Is the window resizable?
	selection reference  -- the selection
	contents anything  -- contents of the window (if any)
	text text  -- the window's text object (if any)
	titled boolean  [r/o]  -- Does the window have a title bar?
	visible boolean  [r/o]  -- Is the window visible?
	zoomable boolean  [r/o]  -- Is the window zoomable?
	zoomed boolean  -- Is the window zoomed?

You should give your first window a name first:

set name of window 1 to "aName"

Then you can reference the window any time by its name:

save window "aName" to file file_path

AppleScript is simple but powerful :lol: