function output = notes(obj, varargin) %NOTES See/edit notes for a pricklypear experiment or run % notes(PP) for notes of an entire experiment (PP without irec) % notes(PP) for notes of a single run (PP with irec) % notes(..., 'edit') to edit the notes for PP % Handle input p = inputParser(); p.addOptional('mode', 'edit', @ischar); p.parse(varargin{:}); p = p.Results; % The object must be an experiment or a saved run assert(~isempty(experiment(obj)), 'Please specify an experiment'); if ~isempty(obj.irec) % The run must be saved assert(obj.irec > 0, 'Only saved runs can have notes'); % The run must exist assert(exist(obj) == true, 'The run was not found'); else % The experiment must exist %assert(exists(obj) == true, 'The experiment was not found'); end % File name if isempty(obj.irec) % Experiment fname = fullfile(datadir(obj), 'experiment_notes.txt'); else % Run fname = fullfile(datadir(obj), sprintf('run_%05i__notes.txt', obj.irec)); end % Mode switch p.mode case {'view' 'read'} if ~exist(fname, 'file') warning('pricklypear:noNotes', 'No notes found for this experiment/run'); return; end txt = fileread(fname); if nargout == 0 fprintf('\n%s\n\n', txt); else output = txt; end case {'edit' 'write'} edit(fname); otherwise error('The provided action was not recognized (must be view/edit)'); end end