Undocumented Secrets of MATLAB
®
-Java Programming518
% Author: Yair Altman
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
try
% Main code here
catch
% Exception handling here
end
Keybindings are normalized using Java’s built-in javax.swing.KeyStroke.getKey-
Stroke() method, to enable the user a very wide range of keystroke naming formats (e.g., ‘Alt-
Control-T’ or ‘ctrl alt t’).
Text can also be computed dynamically by the called macro function. For example, this
macro inserts the current timestamp:
EditorMacro('Alt control t', @(a,b)datestr(now), 'text');
Note the odd-looking denition of datestr: This is because each EditorMacro macro func-
tion must accept at least two input arguments (see the following section for details). It is ok to
ignore these ...