How to find the name of the file that is being edited?
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Alecsander Eitan
am 1 Sep. 2015
Kommentiert: Guillaume
am 3 Sep. 2015
Hi, I would like to write a Matlab script that performs an operation on the file that is being eddited (file that is displayed now in the editor window). To do so, I need to know the name of the file. I was looking all over the places and didn't find the solution. To be more specific, I looking for a solution like gcf() The reason I'm looking for such a solution is that I would like to do some analysis and processing on the eddited file like: Publish (without the Matlab option), save to... Thank you, Alecs
0 Kommentare
Akzeptierte Antwort
Steven Lord
am 1 Sep. 2015
Or you could use the Editor API. Look for help on matlab.desktop.editor for more information -- it seems like getActiveFilename is what you want.
2 Kommentare
Guillaume
am 3 Sep. 2015
Considering the editor API has been introduced in 2011, it would be good if its documentation was discoverable.
I certainly wasn't aware of it since a search in the help browser does not return anything useful. Even a lookfor editor does not return any hint that there's such an api.
Weitere Antworten (2)
Guillaume
am 1 Sep. 2015
See Yair's site on how to access the editor. Accessing the name of the file being currently edited is one of the first example:
desktop = com.mathworks.mde.desk.MLDesktop.getInstance;
jEditor = desktop.getGroupContainer('Editor').getTopLevelAncestor;
jEditor.getTitle
Of course, as it relies on undocumented interfaces, there's no guarantee that it will work in future versions.
Siehe auch
Kategorien
Mehr zu Environment and Settings finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!