IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
ircode_add.m
Go to the documentation of this file.
1 %> @ingroup globals codegen
2 %> @file
3 %> @brief Adds string to auto-generated code buffer (without executing)
4 %> @sa ircode_eval.m
5 %
6 %> @param s Piece of code
7 %> @param title Unused at the moment
8 function ircode_add(s, title)
9 global handles_irootlab IRCODE;
10 
11 if ~iscell(IRCODE.s)
12  IRCODE.s = {};
13  ircode_add(['% ', sprintf('First code sent @ %s.\n', datestr(now))]);
14 end;
15 
16 if isempty(IRCODE.filename)
17  IRCODE.filename = fullfile(pwd(), find_filename('irr_macro', '', 'm'));
18  ircode_add(['% Log filename: ', IRCODE.filename, 10]);
19 end;
20 
21 IRCODE.s{end+1} = s;
22 
23 h = -1;
24 try
25  h = fopen(IRCODE.filename, 'w');
26  fwrite(h, sprintf('%s', IRCODE.s{:}));
27 catch ME15
28  fprintf('ERROR trying to save file %s: %s\nLog was not saved.\n', IRCODE.filename, ME15.message);
29 end;
30 if h ~= -1
31  fclose(h);
32 end;
33 
34 
35 try
36  if ~isempty(handles_irootlab)
37  set(handles_irootlab.editCode, 'String', IRCODE.s);
38  set(handles_irootlab.text_codefilename, 'String', ['File ' IRCODE.filename]);
39  end;
40 catch ME2
41  %> nevermind
42 end;
43 
44 
function ircode_add(in s, in title)
function ircode_eval(in s, in title)
function find_filename(in prefix, in suffix, in extension, in flag_return_ext)