0001 function [s,sobj,cleartags] = iluke_status(s,status,sobj,mode,curtime,cleartags)
0002
0003
0004
0005
0006
0007
0008
0009 sname = inputname(1);
0010
0011 if mode > 1,
0012 fnames = fieldnames(sobj);
0013 fnames(strcmp(fnames,'title')) = [];
0014 fnames(strcmp(fnames,'text')) = [];
0015 end
0016
0017 if iscell(s),
0018 mask = status <= 0;
0019 if any(mask),
0020 if iscell(s(mask(1))),
0021 s(mask) = {{}};
0022 else
0023 s(mask) = {[]};
0024 end
0025 end
0026
0027
0028
0029 if mode <= 1,
0030 if curtime > 0,
0031 if status(curtime) <= 0,
0032 sobj.text.string = '< empty >';
0033 if ~any(strcmp(cleartags{2+curtime},'all')) && ~any(strcmp(cleartags{2+curtime},sname)),
0034 cleartags{2+curtime} = [cleartags{2+curtime},sname];
0035 end
0036 elseif ~isfield(s{curtime},'filename') || isempty(s{curtime}.filename),
0037 sobj.text.string = '< not saved >';
0038 else
0039 sobj.text.string = s{curtime}.filename;
0040 end
0041 elseif curtime == 0,
0042 ns = sum(status > 0);
0043 if ns == 0,
0044 sobj.text.string = '< empty >';
0045 else
0046 sobj.text.string = [num2str(ns),' structures'];
0047 end
0048 else
0049 sobj.text.string = '< empty >';
0050 end
0051 end
0052
0053 elseif status <= 0,
0054 s = [];
0055 if mode <= 1,
0056 sobj.text.string = '< empty >';
0057 end
0058 elseif mode <= 1 && ~isfield(s,'filename') || isempty(s.filename),
0059 sobj.text.string = '< not saved >';
0060 elseif mode <= 1
0061 sobj.text.string = s.filename;
0062 end
0063
0064
0065
0066 if isempty(status),
0067 status = -1;
0068 elseif curtime > 0,
0069 status = status(curtime);
0070 else
0071 status = max(status);
0072 end
0073
0074 if status < 0,
0075 if mode == -1,
0076 sobj.make.state = 'on';
0077 sobj.load.state = 'on';
0078 elseif mode == 0,
0079 sobj.make.state = 'off';
0080 sobj.load.state = 'off';
0081 elseif mode == 1,
0082 sobj.run.state = 'off';
0083 else
0084 for ifield = 1:length(fnames),
0085 sobj.(fnames{ifield}).state = 'off';
0086 end
0087 end
0088 else
0089 if mode <= 0,
0090 sobj.make.state = 'on';
0091 sobj.load.state = 'on';
0092 elseif mode == 1,
0093 sobj.run.state = 'on';
0094 else
0095 for ifield = 1:length(fnames),
0096 sobj.(fnames{ifield}).state = 'on';
0097 end
0098 end
0099 end
0100
0101 if mode <= 1,
0102 if status <= 0,
0103 if mode <= 0,
0104 sobj.save.state = 'off';
0105 end
0106 sobj.clear.state = 'off';
0107 sobj.disp.state = 'off';
0108 sobj.export.state = 'off';
0109 else
0110 if mode <= 0,
0111 sobj.save.state = 'on';
0112 end
0113 sobj.clear.state = 'on';
0114 sobj.disp.state = 'on';
0115 if curtime > 0,
0116 sobj.export.state = 'on';
0117 else
0118 sobj.export.state = 'off';
0119 end
0120 end
0121
0122 if status == 0,
0123 if mode <= 0,
0124 sobj.make.highlight = true;
0125 else
0126 sobj.run.highlight = true;
0127 end
0128 else
0129 if mode <= 0,
0130 sobj.make.highlight = false;
0131 else
0132 sobj.run.highlight = false;
0133 end
0134 end
0135 else
0136 for ifield = 1:length(fnames),
0137 if status == 0,
0138 sobj.(fnames{ifield}).highlight = true;
0139 else
0140 sobj.(fnames{ifield}).highlight = false;
0141 end
0142 end
0143 end
0144
0145