diff options
author | nutricato | 2009-06-04 04:51:29 +0000 |
---|---|---|
committer | nutricato | 2009-06-04 04:51:29 +0000 |
commit | 79f469725862e0bc1ee1be9b7e2d6cdb12911e76 (patch) | |
tree | 0db6989ea1dcb99723f2e5722335d52b2aaaa279 /macros/GeneralFunctions | |
parent | 25f850906710d1da7291f48fa4cb89c4d82ca33b (diff) | |
download | scilab2c-79f469725862e0bc1ee1be9b7e2d6cdb12911e76.tar.gz scilab2c-79f469725862e0bc1ee1be9b7e2d6cdb12911e76.tar.bz2 scilab2c-79f469725862e0bc1ee1be9b7e2d6cdb12911e76.zip |
Diffstat (limited to 'macros/GeneralFunctions')
-rw-r--r-- | macros/GeneralFunctions/PrintStepInfo.sci | 32 | ||||
-rw-r--r-- | macros/GeneralFunctions/PrintStringInfo.sci | 36 | ||||
-rw-r--r-- | macros/GeneralFunctions/filenamefprintf.sci | 15 |
3 files changed, 48 insertions, 35 deletions
diff --git a/macros/GeneralFunctions/PrintStepInfo.sci b/macros/GeneralFunctions/PrintStepInfo.sci index f4a17926..2550e327 100644 --- a/macros/GeneralFunctions/PrintStepInfo.sci +++ b/macros/GeneralFunctions/PrintStepInfo.sci @@ -1,5 +1,5 @@ -function PrintStepInfo(inputstring,filename,outputtype)
-// function PrintStepInfo(inputstring,filename,outputtype)
+function PrintStepInfo(inputstring,filename,outputtype,formattedstring)
+// function PrintStepInfo(inputstring,filename,outputtype,formattedstring)
// -----------------------------------------------------------------
// #RNU_RES_B
// Prints a string by using a predefined format into a file or on
@@ -13,6 +13,8 @@ function PrintStepInfo(inputstring,filename,outputtype) // 'stdout' -> prints only on the stdout.
// 'both' -> prints on both file and stdoud.
// Default is 'stdout'.
+// formattedstring: if 'n' (default) it means that str is considered as a simple string (mputstr).
+// if 'y' then str is considered formatted according to mfprint syntax
// Output data:
//
// #RNU_RES_E
@@ -27,13 +29,15 @@ function PrintStepInfo(inputstring,filename,outputtype) // ------------------------------
// --- Check input arguments. ---
// ------------------------------
-SCI2CNInArgCheck(argn(2),1,3);
+SCI2CNInArgCheck(argn(2),1,4);
-
-if argn(2) < 3
- bothout = 'n';
- if argn(2) < 2
- filename = '';
+if argn(2) < 4
+ formattedstring = 'n';
+ if argn(2) < 3
+ bothout = 'n';
+ if argn(2) < 2
+ filename = '';
+ end
end
end
if (length(filename) == 0)
@@ -57,11 +61,11 @@ if ((outputtype=='both') | (outputtype=='stdout')) end
if ((outputtype=='both') | (outputtype=='file'))
- filenamefprintf(filename,'y',' ');
- filenamefprintf(filename,'y',' ');
- filenamefprintf(filename,'y',blankstring+' '+starstring);
- filenamefprintf(filename,'y',blankstring+'==> '+inputstring);
- filenamefprintf(filename,'y',blankstring+' '+starstring);
- filenamefprintf(filename,'y',' ');
+ filenamefprintf(filename,'y',' ',formattedstring);
+ filenamefprintf(filename,'y',' ',formattedstring);
+ filenamefprintf(filename,'y',blankstring+' '+starstring,formattedstring);
+ filenamefprintf(filename,'y',blankstring+'==> '+inputstring,formattedstring);
+ filenamefprintf(filename,'y',blankstring+' '+starstring,formattedstring);
+ filenamefprintf(filename,'y',' ',formattedstring);
end
endfunction
diff --git a/macros/GeneralFunctions/PrintStringInfo.sci b/macros/GeneralFunctions/PrintStringInfo.sci index 6fd4ec20..a554d122 100644 --- a/macros/GeneralFunctions/PrintStringInfo.sci +++ b/macros/GeneralFunctions/PrintStringInfo.sci @@ -1,5 +1,5 @@ -function PrintStringInfo(str, filename, outputtype, ennewline)
-// function PrintStringInfo(str,filename,outputtype,ennewline)
+function PrintStringInfo(str, filename, outputtype, ennewline,formattedstring)
+// function PrintStringInfo(str,filename,outputtype,ennewline,formattedstring)
// -----------------------------------------------------------------
// #RNU_RES_B
// Prints a string into a file or on the stdout or on both.
@@ -14,6 +14,8 @@ function PrintStringInfo(str, filename, outputtype, ennewline) // Default is 'stdout'.
// ennewline: optional (default = 'y'); If y adds a newline character
// at the end of the input string.
+// formattedstring: if 'n' (default) it means that str is considered as a simple string (mputstr).
+// if 'y' then str is considered formatted according to mfprint syntax
//
// Output data:
// ---
@@ -31,8 +33,10 @@ function PrintStringInfo(str, filename, outputtype, ennewline) // ------------------------------
// --- Check input arguments. ---
// ------------------------------
-SCI2CNInArgCheck(argn(2),0,4);
+SCI2CNInArgCheck(argn(2),0,5);
+if argn(2) < 5
+ formattedstring = 'n';
if argn(2) < 4
ennewline = 'y';
if argn(2) < 3
@@ -45,21 +49,21 @@ SCI2CNInArgCheck(argn(2),0,4); end
end
end
+end
+if (length(filename) == 0) then
+ outputtype = 'stdout'; // Prints only on the stdout.
+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=='stdout')
+ disp(str)
+end
- if (outputtype=='both') | (outputtype=='file')
- if (ennewline=='y')
- filenamefprintf(filename,'y',str);
- else
- filenamefprintf(filename,'n',str);
- end
+if (outputtype=='both') | (outputtype=='file')
+ if (ennewline=='y')
+ filenamefprintf(filename,'y',str,formattedstring);
+ else
+ filenamefprintf(filename,'n',str,formattedstring);
end
+end
endfunction
diff --git a/macros/GeneralFunctions/filenamefprintf.sci b/macros/GeneralFunctions/filenamefprintf.sci index 34875e99..0b64bd88 100644 --- a/macros/GeneralFunctions/filenamefprintf.sci +++ b/macros/GeneralFunctions/filenamefprintf.sci @@ -1,5 +1,5 @@ -function filenamefprintf(filename,ennewline,str)
-// function filenamefprintf(filename,ennewline,str)
+function filenamefprintf(filename,ennewline,str,formattedstring)
+// function filenamefprintf(filename,ennewline,str,formattedstring)
// --------------------------------------------------------------------------------
// Uses the printf to print the string specified by varargin. filenamefprintf
// uses the filename instead of the fid parameter used by fprintf.
@@ -10,6 +10,8 @@ function filenamefprintf(filename,ennewline,str) // Input data:
// filename: string that specifies the name of the file.
// varargin are the input arguments for the printf.
+// formattedstring: if 'n' (default) it means that str is considered as a simple string (mputstr).
+// if 'y' then str is considered formatted according to mfprint syntax
//
// Output data:
// ---
@@ -25,7 +27,7 @@ function filenamefprintf(filename,ennewline,str) // ------------------------------
// --- Check input arguments. ---
// ------------------------------
-SCI2CNInArgCheck(argn(2),3,3);
+SCI2CNInArgCheck(argn(2),4,4);
// [FidReportFile, mess] = mopen(deblank(filename),'at+');
@@ -33,10 +35,13 @@ SCI2CNInArgCheck(argn(2),3,3); if (FidReportFile == -1) then
SCI2Cerror(mess);
end
- if ennewline=='y' then
- mfprintf(FidReportFile, str+'\n');
+ if formattedstring == 'n'
+ mputstr(str,FidReportFile);
else
mfprintf(FidReportFile, str);
+ end
+ if ennewline=='y' then
+ mfprintf(FidReportFile,'\n');
end
mclose(FidReportFile);
|