blob: 36377bdc4328707b72b5429d2aecb3f68b40b6ec (
plain)
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
|
function PrintStringInfo(str, filename, outputtype, ennewline);
// function PrintStringInfo(str,filename,outputtype,ennewline);
// -----------------------------------------------------------------
// Prints a string into a file or on the stdout or on both.
//
// Input data:
// filename: optional parameter, that specifies the output file.
// If filename is '' or it is not provided to the function,
// the string will be printed on the stdout.
// outputtype: 'file' -> prints only on file.
// 'stdout' -> prints only on the stdout.
// 'both' -> prints on both file and stdout.
// Default is 'stdout'.
// ennewline: optional (default = 'y'); If y adds a newline character
// at the end of the input string.
// Output data:
//
// Status:
// 02-Jan-2006 -- Nutricato Raffaele: Author.
// 02-Jan-2006 -- Nutricato Raffaele: TEST OK.
// 02-May-2006 -- Nutricato Raffaele: Added ennewline.
// -----------------------------------------------------------------
if argn(2) < 4
ennewline = 'y';
if argn(2) < 3
outputtype = 'stdout';
if argn(2) < 2
filename = '';
if argn(2) < 1
str = '';
end
end
end
else if argn(2) > 4
SCI2CSCI2Cerror('Incorrect number of input arguments.');
end
end
if (length(filename) == 0) then
outputtype = 'stdout'; // Prints only on the stdout.
end
if (outputtype=='both') | (outputtype=='stdout')
disp(str)
end
if (outputtype=='both') | (outputtype=='file')
if (ennewline=='y')
filenamefprintf(filename,'y',str);
else
filenamefprintf(filename,'n',str);
end
end
endfunction
|