[9adf76]: inst / ufl.m  Maximize  Restore  History

Download this file

69 lines (63 with data), 2.0 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
## Copyright (C) 2014 Eugenio Gianniti <eugenio.gianniti@mail.polimi.it>
##
## This program is free software; you can redistribute it and/or modify it under
## the terms of the GNU General Public License as published by the Free Software
## Foundation; either version 3 of the License, or (at your option) any later
## version.
##
## This program is distributed in the hope that it will be useful, but WITHOUT
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
## details.
##
## You should have received a copy of the GNU General Public License along with
## this program; if not, see <http://www.gnu.org/licenses/>.
## -*- texinfo -*-
## @deftypefn {Function File} ufl [command] line
##
## Writes the given line to a ufl file. Optional commands are:
## @itemize @bullet
## @item start: opens an ufl file. It is possible to specify a name for it,
## otherwise 'default.ufl' will be used.
## @item end: closes an ufl file.
## @end itemize
##
## @end deftypefn
function ufl (varargin)
persistent fid = -1;
filename = "default.ufl";
if (numel (varargin) < 1)
if (fid < 0)
print_usage ();
endif
elseif (! all (cellfun ("ischar", varargin)))
error ("ufl: all arguments should be strings");
elseif (strcmpi (varargin{1}, "start"))
if (fid >= 0)
error ("ufl: a file is already open");
else
if (numel (varargin) > 1)
filename = varargin{2};
if (isempty (regexpi (filename, ".ufl$", "match")))
filename = [filename, ".ufl"];
endif
endif
fid = fopen (filename, "w");
endif
if (fid < 0)
error (["ufl: could not open file ", filename]);
endif
elseif (strcmpi (varargin{1}, "end"))
if (fid < 0)
error ("ufl: no open file");
else
fclose (fid);
fid = -1;
endif
elseif (fid < 0)
error ("ufl: no open file");
else
fprintf (fid, "%s ", varargin{:});
fprintf (fid, "\n");
endif
endfunction

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks