-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetCallerFileFunctionLine.m
More file actions
49 lines (42 loc) · 1.09 KB
/
GetCallerFileFunctionLine.m
File metadata and controls
49 lines (42 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function varargout = GetCallerFileFunctionLine(ReturnStructureFlag)
% returns caller function information: file, name, line
%
% [CallerFile,CallerName,CallerLine] = GetCallerFileFunctionLine
%
% Data = GetCallerFileFunctionLine('ReturnStructure')
% returns structure with fields
% file
% name
% line
%
if exist('ReturnStructureFlag','var')
try
ReturnStructure = strcmpi(ReturnStructureFlag,'ReturnStructure');
catch
ReturnStructure = false;
end
else
ReturnStructure = false;
end
file = 'commandline';
name = 'commandline';
line = 0;
%ST = dbstack('-completenames',2);
ST = dbstack(2);
if ~isempty(ST)
file = ST(1).file;
name = ST(1).name;
line = ST(1).line;
pos = strfind(name,'/');
if ~isempty(pos)
name = name(pos(end)+1:end);
end
end
if ReturnStructure
varargout{1} = struct( 'file',file', 'name',name, 'line',line );
else
varargout{1} = file;
varargout{2} = name;
varargout{3} = line;
end
end