diff options
Diffstat (limited to 'macros/GeneralFunctions')
27 files changed, 1116 insertions, 1116 deletions
diff --git a/macros/GeneralFunctions/Array2String.sci b/macros/GeneralFunctions/Array2String.sci index 27e9aa15..0be04c36 100644 --- a/macros/GeneralFunctions/Array2String.sci +++ b/macros/GeneralFunctions/Array2String.sci @@ -1,40 +1,40 @@ -function [StringArray] = Array2String(InArray);
-// function [StringArray] = Array2String(InArray);
-// -----------------------------------------------------------------
-// #RNU_RES_B
-// Converts an input array into a string. Maximum 2D array are allowed.
-// Ex.: InArray = [10, 4];
-// StringArray = "[10, 4]";
-// #RNU_RES_E
-//
-// Input data:
-// InArray: Input array.
-//
-// Output data:
-// StringArray: array converted into a string.
-//
-// Status:
-// 13-May-2007 -- Nutricato Raffaele: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
+function [StringArray] = Array2String(InArray); +// function [StringArray] = Array2String(InArray); +// ----------------------------------------------------------------- +// #RNU_RES_B +// Converts an input array into a string. Maximum 2D array are allowed. +// Ex.: InArray = [10, 4]; +// StringArray = "[10, 4]"; +// #RNU_RES_E +// +// Input data: +// InArray: Input array. +// +// Output data: +// StringArray: array converted into a string. +// +// Status: +// 13-May-2007 -- Nutricato Raffaele: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- -// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),1,1);
-
-[Nrows,Ncols] = size(InArray);
-
-StringArray = '[';
-for counterrows = 1:Nrows
- for countercols = 1:Ncols
- StringArray = StringArray + string(InArray(counterrows,countercols)) + ',';
- end
- StringArray = part(StringArray,1:(length(StringArray)-1)); // Remove the last ','
- StringArray = StringArray+';';
-end
-StringArray = part(StringArray,1:(length(StringArray)-1)); // Remove the last ';'
-StringArray = StringArray+']';
-endfunction
+// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +[Nrows,Ncols] = size(InArray); + +StringArray = '['; +for counterrows = 1:Nrows + for countercols = 1:Ncols + StringArray = StringArray + string(InArray(counterrows,countercols)) + ','; + end + StringArray = part(StringArray,1:(length(StringArray)-1)); // Remove the last ',' + StringArray = StringArray+';'; +end +StringArray = part(StringArray,1:(length(StringArray)-1)); // Remove the last ';' +StringArray = StringArray+']'; +endfunction diff --git a/macros/GeneralFunctions/ConvertPathMat2C.sci b/macros/GeneralFunctions/ConvertPathMat2C.sci index d73d22c7..7ee5671d 100644 --- a/macros/GeneralFunctions/ConvertPathMat2C.sci +++ b/macros/GeneralFunctions/ConvertPathMat2C.sci @@ -1,61 +1,61 @@ -function OutPath = ConvertPathMat2C(InPath,CPathStyle)
-// function OutPath = ConvertPathMat2C(InPath,CPathStyle)
-// -----------------------------------------------------------------
-// #RNU_RES_B
-// Converts the input path InPath into a path by using the path
-// style specified by CPathStyle.
-// #RNU_RES_E
-//
-// Input data:
-// //NUT: add description here
-//
-// Output data:
-// //NUT: add description here
-//
-// Status:
-// 26-Jan-2008 -- Nutricato Raffaele: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),2,2);
-if (CPathStyle == 'windows')
- OutPath=strsubst(InPath,'/','\');
-elseif (CPathStyle == 'unix')
- OutPath=strsubst(InPath,'\','/');
-elseif (CPathStyle == 'cygwin')
- OutPath=strsubst(InPath,'\','/');
- OutPath=strsubst(OutPath,'A:','/cygdrive/a');
- OutPath=strsubst(OutPath,'B:','/cygdrive/b');
- OutPath=strsubst(OutPath,'C:','/cygdrive/c');
- OutPath=strsubst(OutPath,'D:','/cygdrive/d');
- OutPath=strsubst(OutPath,'E:','/cygdrive/e');
- OutPath=strsubst(OutPath,'F:','/cygdrive/f');
- OutPath=strsubst(OutPath,'G:','/cygdrive/g');
- OutPath=strsubst(OutPath,'H:','/cygdrive/h');
- OutPath=strsubst(OutPath,'I:','/cygdrive/i');
- OutPath=strsubst(OutPath,'J:','/cygdrive/j');
- OutPath=strsubst(OutPath,'K:','/cygdrive/k');
- OutPath=strsubst(OutPath,'L:','/cygdrive/l');
- OutPath=strsubst(OutPath,'M:','/cygdrive/m');
- OutPath=strsubst(OutPath,'N:','/cygdrive/n');
- OutPath=strsubst(OutPath,'O:','/cygdrive/o');
- OutPath=strsubst(OutPath,'P:','/cygdrive/p');
- OutPath=strsubst(OutPath,'Q:','/cygdrive/q');
- OutPath=strsubst(OutPath,'R:','/cygdrive/r');
- OutPath=strsubst(OutPath,'S:','/cygdrive/s');
- OutPath=strsubst(OutPath,'T:','/cygdrive/t');
- OutPath=strsubst(OutPath,'U:','/cygdrive/u');
- OutPath=strsubst(OutPath,'V:','/cygdrive/v');
- OutPath=strsubst(OutPath,'W:','/cygdrive/w');
- OutPath=strsubst(OutPath,'X:','/cygdrive/x');
- OutPath=strsubst(OutPath,'Y:','/cygdrive/y');
- OutPath=strsubst(OutPath,'Z:','/cygdrive/z');
-else
- OutPath = InPath;
-end
-endfunction
+function OutPath = ConvertPathMat2C(InPath,CPathStyle) +// function OutPath = ConvertPathMat2C(InPath,CPathStyle) +// ----------------------------------------------------------------- +// #RNU_RES_B +// Converts the input path InPath into a path by using the path +// style specified by CPathStyle. +// #RNU_RES_E +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 26-Jan-2008 -- Nutricato Raffaele: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,2); +if (CPathStyle == 'windows') + OutPath=strsubst(InPath,'/','\'); +elseif (CPathStyle == 'unix') + OutPath=strsubst(InPath,'\','/'); +elseif (CPathStyle == 'cygwin') + OutPath=strsubst(InPath,'\','/'); + OutPath=strsubst(OutPath,'A:','/cygdrive/a'); + OutPath=strsubst(OutPath,'B:','/cygdrive/b'); + OutPath=strsubst(OutPath,'C:','/cygdrive/c'); + OutPath=strsubst(OutPath,'D:','/cygdrive/d'); + OutPath=strsubst(OutPath,'E:','/cygdrive/e'); + OutPath=strsubst(OutPath,'F:','/cygdrive/f'); + OutPath=strsubst(OutPath,'G:','/cygdrive/g'); + OutPath=strsubst(OutPath,'H:','/cygdrive/h'); + OutPath=strsubst(OutPath,'I:','/cygdrive/i'); + OutPath=strsubst(OutPath,'J:','/cygdrive/j'); + OutPath=strsubst(OutPath,'K:','/cygdrive/k'); + OutPath=strsubst(OutPath,'L:','/cygdrive/l'); + OutPath=strsubst(OutPath,'M:','/cygdrive/m'); + OutPath=strsubst(OutPath,'N:','/cygdrive/n'); + OutPath=strsubst(OutPath,'O:','/cygdrive/o'); + OutPath=strsubst(OutPath,'P:','/cygdrive/p'); + OutPath=strsubst(OutPath,'Q:','/cygdrive/q'); + OutPath=strsubst(OutPath,'R:','/cygdrive/r'); + OutPath=strsubst(OutPath,'S:','/cygdrive/s'); + OutPath=strsubst(OutPath,'T:','/cygdrive/t'); + OutPath=strsubst(OutPath,'U:','/cygdrive/u'); + OutPath=strsubst(OutPath,'V:','/cygdrive/v'); + OutPath=strsubst(OutPath,'W:','/cygdrive/w'); + OutPath=strsubst(OutPath,'X:','/cygdrive/x'); + OutPath=strsubst(OutPath,'Y:','/cygdrive/y'); + OutPath=strsubst(OutPath,'Z:','/cygdrive/z'); +else + OutPath = InPath; +end +endfunction diff --git a/macros/GeneralFunctions/File2StringArray.sci b/macros/GeneralFunctions/File2StringArray.sci index 626cb6ce..a9659ac4 100644 --- a/macros/GeneralFunctions/File2StringArray.sci +++ b/macros/GeneralFunctions/File2StringArray.sci @@ -1,54 +1,54 @@ -function [String_Array,N_Strings] = File2StringArray(InFileName)
-// function [String_Array,N_Strings] = File2StringArray(InFileName)
-// -----------------------------------------------------------------
-// #RNU_RES_B
-// Reads a text file and stores every line into a string array.
-// #RNU_RES_E
-//
-// Input data:
-// InFileName: path+filename of the input file.
-//
-// Output data:
-// String_Array: array of strings containing the lines of the input
-// text file.
-// N_Strings: number of strings stored in String_Array.
-//
-// Status:
-// 10-Nov-2007 -- Raffaele Nutricato: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
+function [String_Array,N_Strings] = File2StringArray(InFileName) +// function [String_Array,N_Strings] = File2StringArray(InFileName) +// ----------------------------------------------------------------- +// #RNU_RES_B +// Reads a text file and stores every line into a string array. +// #RNU_RES_E +// +// Input data: +// InFileName: path+filename of the input file. +// +// Output data: +// String_Array: array of strings containing the lines of the input +// text file. +// N_Strings: number of strings stored in String_Array. +// +// Status: +// 10-Nov-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- -// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),1,1);
-
-
-// -----------------------
-// --- Initialization. ---
-// -----------------------
-N_Strings = 0;
-String_Array = '';
-// ---------------------------
-// --- End Initialization. ---
-// ---------------------------
-
-// --------------------
-// --- Open C file. ---
-// --------------------
-fidfile = SCI2COpenFileRead(InFileName);
-
-// -------------------
-// --- Read lines. ---
-// -------------------
-tmpline = mgetl(fidfile,1);
-while (meof(fidfile) == 0)
- N_Strings = N_Strings + 1;
- String_Array(N_Strings) = tmpline;
- tmpline = mgetl(fidfile,1);
-end
-
-mclose(fidfile);
-endfunction
+// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + + +// ----------------------- +// --- Initialization. --- +// ----------------------- +N_Strings = 0; +String_Array = ''; +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +// -------------------- +// --- Open C file. --- +// -------------------- +fidfile = SCI2COpenFileRead(InFileName); + +// ------------------- +// --- Read lines. --- +// ------------------- +tmpline = mgetl(fidfile,1); +while (meof(fidfile) == 0) + N_Strings = N_Strings + 1; + String_Array(N_Strings) = tmpline; + tmpline = mgetl(fidfile,1); +end + +mclose(fidfile); +endfunction diff --git a/macros/GeneralFunctions/FunName2SciFileName.sci b/macros/GeneralFunctions/FunName2SciFileName.sci index 39ff5b21..97c75545 100644 --- a/macros/GeneralFunctions/FunName2SciFileName.sci +++ b/macros/GeneralFunctions/FunName2SciFileName.sci @@ -1,56 +1,56 @@ -function ScilabFileName = FunName2SciFileName(DirList,InFunName);
-// function ScilabFileName = FunName2SciFileName(DirList,InFunName);
-// -----------------------------------------------------------------
-// #RNU_RES_B
-// This function generates the full path of the scilab file
-// related to the function name (InFunName) specified.
-// In more detail the file "eval(InFunName).sci" file is searched
-// in the directories specified in DirList.
-// #RNU_RES_E
-//
-// Input data:
-// //NUT: add description here
-//
-// Output data:
-// //NUT: add description here
-//
-// Status:
-// 16-Apr-2007 -- Nutricato Raffaele: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
- -// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),2,2);
-
-if (prod(size(DirList)) == 0)
- error(9999, 'Incorrect DirList parameter.');
-end
-
-if (prod(size(InFunName)) == 0)
- error(9999, 'Incorrect InFunName parameter.');
-end
-
-// --- Generate the PathList. ---
-for tmpcounter = 1:max(size(DirList))
- PathList(tmpcounter) = fullfile(DirList(tmpcounter),(InFunName+'.sci'));
-end
-
-// --- Search the .sci file. ---
-ScilabFileName = listfiles(PathList);
-
-// --- Check on the number of .sci files found. ---
-if ((prod(size(ScilabFileName))) > 1)
- disp(ScilabFileName);
- error(9999, 'Found more than one scilab file.');
-end
-
-if ((prod(size(ScilabFileName))) < 1)
- disp(ScilabFileName);
- error(9999, 'Scilab file ""'+InFunName+'.sci"", not found');
-end
-
-endfunction
+function ScilabFileName = FunName2SciFileName(DirList,InFunName); +// function ScilabFileName = FunName2SciFileName(DirList,InFunName); +// ----------------------------------------------------------------- +// #RNU_RES_B +// This function generates the full path of the scilab file +// related to the function name (InFunName) specified. +// In more detail the file "eval(InFunName).sci" file is searched +// in the directories specified in DirList. +// #RNU_RES_E +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 16-Apr-2007 -- Nutricato Raffaele: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,2); + +if (prod(size(DirList)) == 0) + error(9999, 'Incorrect DirList parameter.'); +end + +if (prod(size(InFunName)) == 0) + error(9999, 'Incorrect InFunName parameter.'); +end + +// --- Generate the PathList. --- +for tmpcounter = 1:max(size(DirList)) + PathList(tmpcounter) = fullfile(DirList(tmpcounter),(InFunName+'.sci')); +end + +// --- Search the .sci file. --- +ScilabFileName = listfiles(PathList); + +// --- Check on the number of .sci files found. --- +if ((prod(size(ScilabFileName))) > 1) + disp(ScilabFileName); + error(9999, 'Found more than one scilab file.'); +end + +if ((prod(size(ScilabFileName))) < 1) + disp(ScilabFileName); + error(9999, 'Scilab file ""'+InFunName+'.sci"", not found'); +end + +endfunction diff --git a/macros/GeneralFunctions/IsNanSize.sci b/macros/GeneralFunctions/IsNanSize.sci index 486f6fcc..9a129829 100644 --- a/macros/GeneralFunctions/IsNanSize.sci +++ b/macros/GeneralFunctions/IsNanSize.sci @@ -1,39 +1,39 @@ -function outbool = IsNanSize(instring)
-// function outbool = IsNanSize(instring)
-// -----------------------------------------------------------------
-// #RNU_RES_B
-// It searches for __SCI2CNANSIZE string in the string which specifies the
-// size of the argument. Useful to find if a given size contains
-// a nan value. In this case an error is issued.
-// IsNanSize = '__SCI2CNANSIZE' -> True
-// IsNanSize = 'c*__SCI2CNANSIZE' -> True
-// IsNanSize = 'c+b' -> False
-// #RNU_RES_E
-//
-// Input data:
-// instring: string to analyze.
-//
-// Output data:
-// outbool: %T if nan string has been found.
-//
-// Status:
-// 11-Feb-2008 -- Nutricato Raffaele: Author.
-//
-// Copyright 2008 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),1,1);
-
-
-outbool = %F;
-indexval = strindex(instring,'__SCI2CNANSIZE');
-
-if(length(indexval)>=1)
- outbool = %T;
-end
-
-endfunction
+function outbool = IsNanSize(instring) +// function outbool = IsNanSize(instring) +// ----------------------------------------------------------------- +// #RNU_RES_B +// It searches for __SCI2CNANSIZE string in the string which specifies the +// size of the argument. Useful to find if a given size contains +// a nan value. In this case an error is issued. +// IsNanSize = '__SCI2CNANSIZE' -> True +// IsNanSize = 'c*__SCI2CNANSIZE' -> True +// IsNanSize = 'c+b' -> False +// #RNU_RES_E +// +// Input data: +// instring: string to analyze. +// +// Output data: +// outbool: %T if nan string has been found. +// +// Status: +// 11-Feb-2008 -- Nutricato Raffaele: Author. +// +// Copyright 2008 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + + +outbool = %F; +indexval = strindex(instring,'__SCI2CNANSIZE'); + +if(length(indexval)>=1) + outbool = %T; +end + +endfunction diff --git a/macros/GeneralFunctions/KeyStr2FileStrPos.sci b/macros/GeneralFunctions/KeyStr2FileStrPos.sci index e9fb1c48..6e818ec0 100644 --- a/macros/GeneralFunctions/KeyStr2FileStrPos.sci +++ b/macros/GeneralFunctions/KeyStr2FileStrPos.sci @@ -1,83 +1,83 @@ -function [flag_found,requested_line,line_position] = KeyStr2FileStrPos(filename,key_string,method)
-// function [flag_found,requested_line,line_position] = KeyStr2FileStrPos(filename,key_string,method)
-// --------------------------------------------------------------------------------
-// #RNU_RES_B
-// This function returns a line and its position from a specified ASCII file.
-// The line and the position returned starts with a key string specified in the
-// input parameters.
-//
-// Input data:
-// filename: path + name of the ASCII file.
-// key_string: string that specifies the initial portion of the line to return.
-// method: 'cut': in the returned line will be removed the key_string
-// 'no_cut': (default), in the returned line will not be removed the key_string
-//
-// Output data:
-// flag_found: 0 if the line is not found or an error occured.
-// 1 if the search succeed.
-// requested_line: is the line in the file which contains as first characters those
-// specified in the key_string.
-// line_position: position of the line in the file; the first line in the file
-// is the line number 1.
-// #RNU_RES_E
-//
-//
-// Status:
-// 08-Jul-2002 -- Author: Raffaele Nutricato
-// 08-Jul-2002 -- Raffaele Nutricato: Revision OK
-// 23-Nov-2004 -- Raffaele Nutricato: Changed disp to warning in if (flag_found == 0).
-// It allows to disable the message it generates
-// by using warning off.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
+function [flag_found,requested_line,line_position] = KeyStr2FileStrPos(filename,key_string,method) +// function [flag_found,requested_line,line_position] = KeyStr2FileStrPos(filename,key_string,method) +// -------------------------------------------------------------------------------- +// #RNU_RES_B +// This function returns a line and its position from a specified ASCII file. +// The line and the position returned starts with a key string specified in the +// input parameters. +// +// Input data: +// filename: path + name of the ASCII file. +// key_string: string that specifies the initial portion of the line to return. +// method: 'cut': in the returned line will be removed the key_string +// 'no_cut': (default), in the returned line will not be removed the key_string +// +// Output data: +// flag_found: 0 if the line is not found or an error occured. +// 1 if the search succeed. +// requested_line: is the line in the file which contains as first characters those +// specified in the key_string. +// line_position: position of the line in the file; the first line in the file +// is the line number 1. +// #RNU_RES_E +// +// +// Status: +// 08-Jul-2002 -- Author: Raffaele Nutricato +// 08-Jul-2002 -- Raffaele Nutricato: Revision OK +// 23-Nov-2004 -- Raffaele Nutricato: Changed disp to warning in if (flag_found == 0). +// It allows to disable the message it generates +// by using warning off. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- -// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),2,3);
-
-
-if (argn(2) == 2)
- method = 'no_cut';
-end
-method = convstr(method, 'u');
-
-// Initialize output parameters
-flag_found = 0;
-requested_line = '';
-line_position = 0;
-
-// Open the text file (read only)
-[fid,mess] = mopen(filename,'r');
-if ( fid == -1 )
- disp(['Cannot open: '+filename])
- disp(mess);
- flag_found = 0;
- return;
-end
-
-// loop on the lines of the file
-num_chars = length(key_string);
-while (meof(fid) == 0)
- check_string = fgetl(fid);
- line_position = line_position + 1;
- if (key_string == check_string) & (key_string == num_chars) then
- flag_found = 1;
- requested_line = check_string;
- if (method =='cut') then
- requested_line(1:num_chars) = [];
- end
- mclose(fid);
- return;
- end
-end
-
-if (flag_found == 0)
- warning('Warning: string ' + key_string + ' not found in file: ' + filename);
- mclose(fid);
-end
-
-mclose(fid);
-endfunction
+// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,3); + + +if (argn(2) == 2) + method = 'no_cut'; +end +method = convstr(method, 'u'); + +// Initialize output parameters +flag_found = 0; +requested_line = ''; +line_position = 0; + +// Open the text file (read only) +[fid,mess] = mopen(filename,'r'); +if ( fid == -1 ) + disp(['Cannot open: '+filename]) + disp(mess); + flag_found = 0; + return; +end + +// loop on the lines of the file +num_chars = length(key_string); +while (meof(fid) == 0) + check_string = fgetl(fid); + line_position = line_position + 1; + if (key_string == check_string) & (key_string == num_chars) then + flag_found = 1; + requested_line = check_string; + if (method =='cut') then + requested_line(1:num_chars) = []; + end + mclose(fid); + return; + end +end + +if (flag_found == 0) + warning('Warning: string ' + key_string + ' not found in file: ' + filename); + mclose(fid); +end + +mclose(fid); +endfunction diff --git a/macros/GeneralFunctions/PrintStringInfo.sci b/macros/GeneralFunctions/PrintStringInfo.sci index a554d122..72b4e320 100644 --- a/macros/GeneralFunctions/PrintStringInfo.sci +++ b/macros/GeneralFunctions/PrintStringInfo.sci @@ -1,69 +1,69 @@ -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.
-//
-// 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.
-// 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
-//
-// Status:
-// 02-Jan-2006 -- Nutricato Raffaele: Author.
-// 02-Jan-2006 -- Nutricato Raffaele: TEST OK.
-// 02-May-2006 -- Nutricato Raffaele: Added ennewline.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
+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. +// +// 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. +// 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 +// +// Status: +// 02-Jan-2006 -- Nutricato Raffaele: Author. +// 02-Jan-2006 -- Nutricato Raffaele: TEST OK. +// 02-May-2006 -- Nutricato Raffaele: Added ennewline. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- -// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),0,5);
-
-if argn(2) < 5
- formattedstring = 'n';
- 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
- 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,formattedstring);
- else
- filenamefprintf(filename,'n',str,formattedstring);
- end
-end
-
-endfunction
+// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),0,5); + +if argn(2) < 5 + formattedstring = 'n'; + 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 + 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,formattedstring); + else + filenamefprintf(filename,'n',str,formattedstring); + end +end + +endfunction diff --git a/macros/GeneralFunctions/ReadStringCard.sci b/macros/GeneralFunctions/ReadStringCard.sci index a4525d90..d44a22cf 100644 --- a/macros/GeneralFunctions/ReadStringCard.sci +++ b/macros/GeneralFunctions/ReadStringCard.sci @@ -1,61 +1,61 @@ -function cardvalue = ReadStringCard(filename,cardname,commentdelim,enableerror)
-// function cardvalue = ReadStringCard(filename,cardname,commentdelim,enableerror)
-// -----------------------------------------------------------------
-// #RNU_RES_B
-// Reads the string associated to the card cardname placed
-// in filename.
-// The value of cardname is assumed to be a string.
-// If the card is not found an error will occur.
-//
-// Input data:
-// filename: full path + name of the file where the card
-// is being searched.
-// cardname: string with the name of the card.
-// commentdelim: specifies a character for an eventual comment
-// (to be discarded) after the card value.
-// enableerror: 'y' enable error message.
-// 'n' enable warning message.
-//
-// Output data:
-// cardvalue: string associated to the card. Blanks characters
-// are discarded.
-// #RNU_RES_E
-//
-// Status:
-// 06-Feb-2004 -- Nutricato Raffaele: Author.
-// 06-Feb-2004 -- Nutricato Raffaele: TEST OK.
-// 25-Jun-2004 -- Nutricato Raffaele: Added Comment delimiter
-// and enableerror as input parameter.
-// 13-Apr-2007 -- Intelligente Fabio: Rewritten from Matlab to Scilab.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
+function cardvalue = ReadStringCard(filename,cardname,commentdelim,enableerror) +// function cardvalue = ReadStringCard(filename,cardname,commentdelim,enableerror) +// ----------------------------------------------------------------- +// #RNU_RES_B +// Reads the string associated to the card cardname placed +// in filename. +// The value of cardname is assumed to be a string. +// If the card is not found an error will occur. +// +// Input data: +// filename: full path + name of the file where the card +// is being searched. +// cardname: string with the name of the card. +// commentdelim: specifies a character for an eventual comment +// (to be discarded) after the card value. +// enableerror: 'y' enable error message. +// 'n' enable warning message. +// +// Output data: +// cardvalue: string associated to the card. Blanks characters +// are discarded. +// #RNU_RES_E +// +// Status: +// 06-Feb-2004 -- Nutricato Raffaele: Author. +// 06-Feb-2004 -- Nutricato Raffaele: TEST OK. +// 25-Jun-2004 -- Nutricato Raffaele: Added Comment delimiter +// and enableerror as input parameter. +// 13-Apr-2007 -- Intelligente Fabio: Rewritten from Matlab to Scilab. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- -// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),2,3);
-
-if argn(2) == 2 then
- commentdelim = ' ';
- enableerror = 'y';
-
-elseif argn(2) == 3 then
- enableerror = 'y';
-end
-
-[flag_found,requested_line,dummy2] = ...
- KeyString2FileStringPos(filename,cardname,'cut');
-cardvalue = stripblanks(strtok(requested_line,commentdelim));
-clear requested_line dummy2
-
-if (flag_found == 0) then
- if (enableerror == 'y') then
- error(9999, cardname+' not found');
- else
- warning([cardname,' not found']);
- end
-end
-
-endfunction
+// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,3); + +if argn(2) == 2 then + commentdelim = ' '; + enableerror = 'y'; + +elseif argn(2) == 3 then + enableerror = 'y'; +end + +[flag_found,requested_line,dummy2] = ... + KeyString2FileStringPos(filename,cardname,'cut'); +cardvalue = stripblanks(strtok(requested_line,commentdelim)); +clear requested_line dummy2 + +if (flag_found == 0) then + if (enableerror == 'y') then + error(9999, cardname+' not found'); + else + warning([cardname,' not found']); + end +end + +endfunction diff --git a/macros/GeneralFunctions/SCI2CCreateDir.sci b/macros/GeneralFunctions/SCI2CCreateDir.sci index dcc39c3e..c74ef124 100644 --- a/macros/GeneralFunctions/SCI2CCreateDir.sci +++ b/macros/GeneralFunctions/SCI2CCreateDir.sci @@ -1,31 +1,31 @@ -function SCI2CCreateDir(OutDir)
-// function SCI2CCreateDir(OutDir)
-// -----------------------------------------------------------------
-// Create the dir OutDir.
-//
-// Input data:
-// OutDir: full path (absolute or relative) of the directory to be created.
-//
-// Output data:
-// ---
-//
-// Status:
-// 25-Jun-2007 -- Raffaele Nutricato: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
+function SCI2CCreateDir(OutDir) +// function SCI2CCreateDir(OutDir) +// ----------------------------------------------------------------- +// Create the dir OutDir. +// +// Input data: +// OutDir: full path (absolute or relative) of the directory to be created. +// +// Output data: +// --- +// +// Status: +// 25-Jun-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- -// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),1,1);
-
-[tmppath,tmpfname,tmpextension]=fileparts(OutDir) ;
-
-status_dir = mkdir(tmppath,tmpfname+tmpextension) ;
-if (status_dir == 0)
- error(9999, 'Cannot create: '+OutDir);
-end
-
-endfunction
+// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +[tmppath,tmpfname,tmpextension]=fileparts(OutDir) ; + +status_dir = mkdir(tmppath,tmpfname+tmpextension) ; +if (status_dir == 0) + error(9999, 'Cannot create: '+OutDir); +end + +endfunction diff --git a/macros/GeneralFunctions/SCI2CFindFile.sci b/macros/GeneralFunctions/SCI2CFindFile.sci index f7271e2e..7cb3e104 100644 --- a/macros/GeneralFunctions/SCI2CFindFile.sci +++ b/macros/GeneralFunctions/SCI2CFindFile.sci @@ -1,40 +1,40 @@ -function [FlagFound,SCIFileName] = SCI2CFindFile(PathList,FileName)
-// function [FlagFound,SCIFileName] = SCI2CFindFile(PathList,FileName)
-// -----------------------------------------------------------------
-// //NUT: add description here
-//
-// Input data:
-// //NUT: add description here
-//
-// Output data:
-// //NUT: add description here
-//
-// Status:
-// 11-Jul-2007 -- Nutricato Raffaele: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),2,2);
-FlagFound = 0;
-SCIFileName = '';
-
-// Perform the search in the user .sci files.
-Nscipaths = size(PathList,1);
-counterscipaths = 1;
-while ((FlagFound == 0) & (counterscipaths <= Nscipaths))
- dirscifilename = PathList(counterscipaths);
- fullpathscifilename = fullfile(dirscifilename,FileName);
- if (SCI2Cfileexist(dirscifilename,FileName))
- // It is a function of the USER2C library.
- FlagFound = 1;
- SCIFileName = fullpathscifilename;
- end
- counterscipaths = counterscipaths + 1;
-end
-
-endfunction
+function [FlagFound,SCIFileName] = SCI2CFindFile(PathList,FileName) +// function [FlagFound,SCIFileName] = SCI2CFindFile(PathList,FileName) +// ----------------------------------------------------------------- +// //NUT: add description here +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 11-Jul-2007 -- Nutricato Raffaele: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,2); +FlagFound = 0; +SCIFileName = ''; + +// Perform the search in the user .sci files. +Nscipaths = size(PathList,1); +counterscipaths = 1; +while ((FlagFound == 0) & (counterscipaths <= Nscipaths)) + dirscifilename = PathList(counterscipaths); + fullpathscifilename = fullfile(dirscifilename,FileName); + if (SCI2Cfileexist(dirscifilename,FileName)) + // It is a function of the USER2C library. + FlagFound = 1; + SCIFileName = fullpathscifilename; + end + counterscipaths = counterscipaths + 1; +end + +endfunction diff --git a/macros/GeneralFunctions/SCI2CNInArgCheck.sci b/macros/GeneralFunctions/SCI2CNInArgCheck.sci index 71b93328..3c8dcb2b 100644 --- a/macros/GeneralFunctions/SCI2CNInArgCheck.sci +++ b/macros/GeneralFunctions/SCI2CNInArgCheck.sci @@ -1,26 +1,26 @@ -function SCI2CNInArgCheck(NInArgs,MinNArgs,MaxNArgs)
-// function SCI2CNInArgCheck(NInArgs,MinNArgs,MaxNArgs)
-// -----------------------------------------------------------------
-// #RNU_RES_B
-// Check that NInArgs is in the range specified by MinNArgs and
-// MaxNArgs.
-//
-// Input data:
-// NInArgs: number of input arguments of the function under test.
-// MinNArgs: minimum number of input arguments allowed.
-// MaxNArgs: maximum number of input arguments allowed.
-//
-// Output data:
-// ---
-// #RNU_RES_E
-//
-// Status:
-// 23-Nov-2007 -- Raffaele Nutricato: Author.
-//
-// Copyright 2007 Raffaele Nutricato
-// -----------------------------------------------------------------
-
-if ((NInArgs < MinNArgs) | (NInArgs > MaxNArgs))
- error(9999, 'Incorrect number of input arguments.');
-end
-endfunction
+function SCI2CNInArgCheck(NInArgs,MinNArgs,MaxNArgs) +// function SCI2CNInArgCheck(NInArgs,MinNArgs,MaxNArgs) +// ----------------------------------------------------------------- +// #RNU_RES_B +// Check that NInArgs is in the range specified by MinNArgs and +// MaxNArgs. +// +// Input data: +// NInArgs: number of input arguments of the function under test. +// MinNArgs: minimum number of input arguments allowed. +// MaxNArgs: maximum number of input arguments allowed. +// +// Output data: +// --- +// #RNU_RES_E +// +// Status: +// 23-Nov-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato +// ----------------------------------------------------------------- + +if ((NInArgs < MinNArgs) | (NInArgs > MaxNArgs)) + error(9999, 'Incorrect number of input arguments.'); +end +endfunction diff --git a/macros/GeneralFunctions/SCI2COpenFileRead.sci b/macros/GeneralFunctions/SCI2COpenFileRead.sci index 1ad60ce5..1132a507 100644 --- a/macros/GeneralFunctions/SCI2COpenFileRead.sci +++ b/macros/GeneralFunctions/SCI2COpenFileRead.sci @@ -1,30 +1,30 @@ -function fidnumber = SCI2COpenFileRead(filename)
-// function fidnumber = SCI2COpenFileRead(filename)
-// --------------------------------------------------------------------------------
-// Open a file in read mode.
-//
-// Input data:
-// filename: path + name of the file to read.
-//
-// Output data:
-// fidnumber: file identifier.
-//
-// Status:
-// 27-Oct-2007 -- Raffaele Nutricato: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),1,1);
-
-// --- Open the .sci file (read only). ---
-[fidnumber,fiderror] = mopen(filename,'r');
-if (fiderror < 0)
- SCI2Cerror(['Cannot open (in read mode): '+filename]);
-end
-
-endfunction
+function fidnumber = SCI2COpenFileRead(filename) +// function fidnumber = SCI2COpenFileRead(filename) +// -------------------------------------------------------------------------------- +// Open a file in read mode. +// +// Input data: +// filename: path + name of the file to read. +// +// Output data: +// fidnumber: file identifier. +// +// Status: +// 27-Oct-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +// --- Open the .sci file (read only). --- +[fidnumber,fiderror] = mopen(filename,'r'); +if (fiderror < 0) + SCI2Cerror(['Cannot open (in read mode): '+filename]); +end + +endfunction diff --git a/macros/GeneralFunctions/SCI2COpenFileWrite.sci b/macros/GeneralFunctions/SCI2COpenFileWrite.sci index f87aef87..37b0c9d8 100644 --- a/macros/GeneralFunctions/SCI2COpenFileWrite.sci +++ b/macros/GeneralFunctions/SCI2COpenFileWrite.sci @@ -1,30 +1,30 @@ -function fidnumber = SCI2COpenFileWrite(filename)
-// function fidnumber = SCI2COpenFileWrite(filename)
-// --------------------------------------------------------------------------------
-// Open a file in write mode.
-//
-// Input data:
-// filename: path + name of the file to be written.
-//
-// Output data:
-// fidnumber: file identifier.
-//
-// Status:
-// 27-Oct-2007 -- Raffaele Nutricato: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),1,1);
-
-// --- Open the .sci file (write mode). ---
-[fidnumber,fiderror] = mopen(filename,'w');
-if (fiderror < 0)
- error(9999, 'Cannot open (in write mode): '+filename);
-end
-
-endfunction
+function fidnumber = SCI2COpenFileWrite(filename) +// function fidnumber = SCI2COpenFileWrite(filename) +// -------------------------------------------------------------------------------- +// Open a file in write mode. +// +// Input data: +// filename: path + name of the file to be written. +// +// Output data: +// fidnumber: file identifier. +// +// Status: +// 27-Oct-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +// --- Open the .sci file (write mode). --- +[fidnumber,fiderror] = mopen(filename,'w'); +if (fiderror < 0) + error(9999, 'Cannot open (in write mode): '+filename); +end + +endfunction diff --git a/macros/GeneralFunctions/SCI2CTemplate.sci b/macros/GeneralFunctions/SCI2CTemplate.sci index e47bdd00..4166651b 100644 --- a/macros/GeneralFunctions/SCI2CTemplate.sci +++ b/macros/GeneralFunctions/SCI2CTemplate.sci @@ -1,32 +1,32 @@ -function out = SCI2CTemplate(in1,in2)
-// function out = SCI2CTemplate(in1,in2)
-// -----------------------------------------------------------------
-// This is a template function which shows how to comment functions.
-//
-// Input data:
-// in1: input argument number 1
-// in2: input argument number 2
-//
-// Output data:
-// out: output argument number 1
-//
-// Status:
-// 03-Jan-2008 -- Raffaele Nutricato: Author.
-//
-// Copyright 2008 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),2,2);
-
-// -----------------------
-// --- Initialization. ---
-// -----------------------
-// ---------------------------
-// --- End Initialization. ---
-// ---------------------------
-
-endfunction
+function out = SCI2CTemplate(in1,in2) +// function out = SCI2CTemplate(in1,in2) +// ----------------------------------------------------------------- +// This is a template function which shows how to comment functions. +// +// Input data: +// in1: input argument number 1 +// in2: input argument number 2 +// +// Output data: +// out: output argument number 1 +// +// Status: +// 03-Jan-2008 -- Raffaele Nutricato: Author. +// +// Copyright 2008 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,2); + +// ----------------------- +// --- Initialization. --- +// ----------------------- +// --------------------------- +// --- End Initialization. --- +// --------------------------- + +endfunction diff --git a/macros/GeneralFunctions/SCI2Ccopyfile.sci b/macros/GeneralFunctions/SCI2Ccopyfile.sci index f95c29ef..40d43f40 100644 --- a/macros/GeneralFunctions/SCI2Ccopyfile.sci +++ b/macros/GeneralFunctions/SCI2Ccopyfile.sci @@ -1,49 +1,49 @@ -function SCI2Ccopyfile(InFileName,OutFileName,CopyMode)
-// function SCI2Ccopyfile(InFileName,OutFileName,CopyMode)
-// -----------------------------------------------------------------
-// #RNU_RES_B
-// Copy the contents of infile into outfile. Append mode is used.
-//
-// Input data:
-// InFileName: path+filename of the input file.
-// OutFileName: path+filename of the input file.
-// CopyMode: 'append' or 'overwrite'
-// #RNU_RES_E
-//
-// Output data:
-// ---
-//
-// Status:
-// 23-Nov-2007 -- Raffaele Nutricato: Author.
-//
-// Copyright 2007 Raffaele Nutricato
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),3,3);
-
-if (CopyMode == 'append')
- // ------------------------
- // --- Open Input file. ---
- // ------------------------
- fidIn = SCI2COpenFileRead(InFileName);
-
- // -------------------
- // --- Read lines. ---
- // -------------------
- tmpline = mgetl(fidIn,1);
- while (meof(fidIn) == 0)
- PrintStringInfo(tmpline, OutFileName, 'file', 'y');
- tmpline = mgetl(fidIn,1);
- end
- mclose(fidIn);
-elseif (CopyMode == 'overwrite')
- PrintStringInfo(' ', OutFileName, 'file', 'y'); // Cannot use scilab copyfile when the directory is empty!.
- copyfile(InFileName,OutFileName);
-else
- SCI2Cerror('Unknown CopyMode: ""'+CopyMode+'""');
-end
-
-endfunction
+function SCI2Ccopyfile(InFileName,OutFileName,CopyMode) +// function SCI2Ccopyfile(InFileName,OutFileName,CopyMode) +// ----------------------------------------------------------------- +// #RNU_RES_B +// Copy the contents of infile into outfile. Append mode is used. +// +// Input data: +// InFileName: path+filename of the input file. +// OutFileName: path+filename of the input file. +// CopyMode: 'append' or 'overwrite' +// #RNU_RES_E +// +// Output data: +// --- +// +// Status: +// 23-Nov-2007 -- Raffaele Nutricato: Author. +// +// Copyright 2007 Raffaele Nutricato +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),3,3); + +if (CopyMode == 'append') + // ------------------------ + // --- Open Input file. --- + // ------------------------ + fidIn = SCI2COpenFileRead(InFileName); + + // ------------------- + // --- Read lines. --- + // ------------------- + tmpline = mgetl(fidIn,1); + while (meof(fidIn) == 0) + PrintStringInfo(tmpline, OutFileName, 'file', 'y'); + tmpline = mgetl(fidIn,1); + end + mclose(fidIn); +elseif (CopyMode == 'overwrite') + PrintStringInfo(' ', OutFileName, 'file', 'y'); // Cannot use scilab copyfile when the directory is empty!. + copyfile(InFileName,OutFileName); +else + SCI2Cerror('Unknown CopyMode: ""'+CopyMode+'""'); +end + +endfunction diff --git a/macros/GeneralFunctions/SCI2Cfileexist.sci b/macros/GeneralFunctions/SCI2Cfileexist.sci index 05dbf590..d01a283d 100644 --- a/macros/GeneralFunctions/SCI2Cfileexist.sci +++ b/macros/GeneralFunctions/SCI2Cfileexist.sci @@ -1,38 +1,38 @@ -function ExistTest = SCI2Cfileexist(InDir,FileName)
-// function ExistTest = SCI2Cfileexist(InDir,FileName)
-// -----------------------------------------------------------------
-// Searches for the file FileName in the directory InDir.
-// Return %F if it doesn't exist.
-//
-// Input data:
-// //NUT: add description here
-//
-// Output data:
-// //NUT: add description here
-//
-// Status:
-// 12-Jun-2007 -- Nutricato Raffaele: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),2,2);
-
-tmppwd = pwd();
-cd(InDir);
-allfiles = ls(FileName);
-cd(tmppwd);
-
-if (size(allfiles,1) == 0)
- ExistTest = %F;
-elseif (size(allfiles,1) == 1)
- ExistTest = %T;
-else
- SCI2Cerror('Very Strange! Found more than one file with the same name.');
-end
-
-endfunction
+function ExistTest = SCI2Cfileexist(InDir,FileName) +// function ExistTest = SCI2Cfileexist(InDir,FileName) +// ----------------------------------------------------------------- +// Searches for the file FileName in the directory InDir. +// Return %F if it doesn't exist. +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 12-Jun-2007 -- Nutricato Raffaele: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,2); + +tmppwd = pwd(); +cd(InDir); +allfiles = ls(FileName); +cd(tmppwd); + +if (size(allfiles,1) == 0) + ExistTest = %F; +elseif (size(allfiles,1) == 1) + ExistTest = %T; +else + SCI2Cerror('Very Strange! Found more than one file with the same name.'); +end + +endfunction diff --git a/macros/GeneralFunctions/SCI2Cflipud.sci b/macros/GeneralFunctions/SCI2Cflipud.sci index 2e988c1b..6fe841fd 100644 --- a/macros/GeneralFunctions/SCI2Cflipud.sci +++ b/macros/GeneralFunctions/SCI2Cflipud.sci @@ -1,40 +1,40 @@ -function OutputData = SCI2Cflipud(InputData)
-// function OutputData = SCI2Cflipud(InputData)
-// -----------------------------------------------------------------
-// #RNU_RES_B
-// Inverts (flips) the position of the arguments of InputData.
-// Input data can be a struct or an array.
-// Ex.:
-// A(1) = 'one';
-// A(2) = 'two';
-// A(3) = 'three';
-// B = SCI2Cflipud(A);
-// B(1) = 'three';
-// B(2) = 'two';
-// B(3) = 'one';
-//
-// Input data:
-// InputData: input array or structure.
-//
-// Output data:
-// OutputData: flipped version of the input array.
-//
-// #RNU_RES_E
-// Status:
-// 12-May-2007 -- Nutricato Raffaele: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),1,1);
-
-NInputs = size(InputData,1);
-OutputData = InputData; // To be sure that they will have the same structure.
-for cnt = 1:NInputs
- OutputData(cnt) = InputData(NInputs-cnt+1);
-end
-endfunction
+function OutputData = SCI2Cflipud(InputData) +// function OutputData = SCI2Cflipud(InputData) +// ----------------------------------------------------------------- +// #RNU_RES_B +// Inverts (flips) the position of the arguments of InputData. +// Input data can be a struct or an array. +// Ex.: +// A(1) = 'one'; +// A(2) = 'two'; +// A(3) = 'three'; +// B = SCI2Cflipud(A); +// B(1) = 'three'; +// B(2) = 'two'; +// B(3) = 'one'; +// +// Input data: +// InputData: input array or structure. +// +// Output data: +// OutputData: flipped version of the input array. +// +// #RNU_RES_E +// Status: +// 12-May-2007 -- Nutricato Raffaele: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +NInputs = size(InputData,1); +OutputData = InputData; // To be sure that they will have the same structure. +for cnt = 1:NInputs + OutputData(cnt) = InputData(NInputs-cnt+1); +end +endfunction diff --git a/macros/GeneralFunctions/SCI2Cmdelete.sci b/macros/GeneralFunctions/SCI2Cmdelete.sci index d19233dc..62dd4b89 100644 --- a/macros/GeneralFunctions/SCI2Cmdelete.sci +++ b/macros/GeneralFunctions/SCI2Cmdelete.sci @@ -1,33 +1,33 @@ -function SCI2Cmdelete(InFile)
-// function SCI2Cmdelete(InFile)
-// -----------------------------------------------------------------
-// #RNU_RES_B
-// Deletes the input files only if the file really exists.
-// This avoids the issuing of the error generated by mdelete.
-//
-// Input data:
-// InFile: full path of the file to be deleted.
-//
-// Output data:
-// #RNU_RES_E
-//
-// Status:
-// 12-Apr-2007 -- Nutricato Raffaele: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),1,1);
-
-[Inx,Inierr]=fileinfo(InFile);
-if Inierr == 0
- mdelete(InFile);//NUT: questa stampa a video il file che sta cancellando.
- //NUT ho fatto delle altre prove e mi funzionava tutto. solo che quando
- //NUT eseguo il codice scilab to c mi stampa a video tutto il nome del file.
-end
-
-endfunction
+function SCI2Cmdelete(InFile) +// function SCI2Cmdelete(InFile) +// ----------------------------------------------------------------- +// #RNU_RES_B +// Deletes the input files only if the file really exists. +// This avoids the issuing of the error generated by mdelete. +// +// Input data: +// InFile: full path of the file to be deleted. +// +// Output data: +// #RNU_RES_E +// +// Status: +// 12-Apr-2007 -- Nutricato Raffaele: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +[Inx,Inierr]=fileinfo(InFile); +if Inierr == 0 + mdelete(InFile);//NUT: questa stampa a video il file che sta cancellando. + //NUT ho fatto delle altre prove e mi funzionava tutto. solo che quando + //NUT eseguo il codice scilab to c mi stampa a video tutto il nome del file. +end + +endfunction diff --git a/macros/GeneralFunctions/SCI2Cresize.sci b/macros/GeneralFunctions/SCI2Cresize.sci index ba78fde0..da4fd967 100644 --- a/macros/GeneralFunctions/SCI2Cresize.sci +++ b/macros/GeneralFunctions/SCI2Cresize.sci @@ -1,33 +1,33 @@ -function out = SCI2Cresize(in)
-// function out = SCI2Cresize(in)
-// -----------------------------------------------------------------
-// #RNU_RES_B
-// It is a dummy function used by the programmer to specify at a given
-// point that a variable is changing its size. This will be translated
-// into C code by re-assigning the size array.
-// Next releases of this function will include check to avoid
-// increment of the size outside the limits specified by the first
-// initialization of the variable.
-//
-// Input data:
-// in: input variable to be resized
-//
-// Output data:
-// out: resized variable
-//
-// #RNU_RES_E
-// Status:
-// 10-Jun-2008 -- Nutricato Raffaele: Author.
-//
-// Copyright 2008 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),1,1);
-
-out = in;
-
-endfunction
+function out = SCI2Cresize(in) +// function out = SCI2Cresize(in) +// ----------------------------------------------------------------- +// #RNU_RES_B +// It is a dummy function used by the programmer to specify at a given +// point that a variable is changing its size. This will be translated +// into C code by re-assigning the size array. +// Next releases of this function will include check to avoid +// increment of the size outside the limits specified by the first +// initialization of the variable. +// +// Input data: +// in: input variable to be resized +// +// Output data: +// out: resized variable +// +// #RNU_RES_E +// Status: +// 10-Jun-2008 -- Nutricato Raffaele: Author. +// +// Copyright 2008 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +out = in; + +endfunction diff --git a/macros/GeneralFunctions/SCI2Cstring.sci b/macros/GeneralFunctions/SCI2Cstring.sci index cf6d4370..5b16c250 100644 --- a/macros/GeneralFunctions/SCI2Cstring.sci +++ b/macros/GeneralFunctions/SCI2Cstring.sci @@ -1,34 +1,34 @@ -function outstring = SCI2Cstring(innum)
-// function outstring = SCI2Cstring(innum)
-// -----------------------------------------------------------------
-// #RNU_RES_B
-// It fixes the bug of string function when applied to
-// exponential formats:
-// Example:
-// -->string(10e-10)
-// ans =
-// 1.000D-09
-// Note how the "D" is syntactically wrong.
-//
-// Input data:
-// innnum: input number to be converted into string.
-//
-// Output data:
-// outstring: string containing the conversion.
-// #RNU_RES_E
-//
-// Status:
-// 07-May-2008 -- Nutricato Raffaele: Author.
-//
-// Copyright 2008 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),1,1);
-
-outstring=strsubst(string(innum),'D','e');
-
-endfunction
+function outstring = SCI2Cstring(innum) +// function outstring = SCI2Cstring(innum) +// ----------------------------------------------------------------- +// #RNU_RES_B +// It fixes the bug of string function when applied to +// exponential formats: +// Example: +// -->string(10e-10) +// ans = +// 1.000D-09 +// Note how the "D" is syntactically wrong. +// +// Input data: +// innnum: input number to be converted into string. +// +// Output data: +// outstring: string containing the conversion. +// #RNU_RES_E +// +// Status: +// 07-May-2008 -- Nutricato Raffaele: Author. +// +// Copyright 2008 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +outstring=strsubst(string(innum),'D','e'); + +endfunction diff --git a/macros/GeneralFunctions/SCI2Cstrncmp.sci b/macros/GeneralFunctions/SCI2Cstrncmp.sci index 54a5e148..1d9f7c91 100644 --- a/macros/GeneralFunctions/SCI2Cstrncmp.sci +++ b/macros/GeneralFunctions/SCI2Cstrncmp.sci @@ -1,27 +1,27 @@ -function res = SCI2Cstrncmp(s1,s2,n)
-// function res = SCI2Cstrncmp(s1,s2,n)
-// -----------------------------------------------------------------
-// This function compares first n characters of strings s1 and s2.
-// SCI2Cstrncmp(s1,s2,n) returns 1logical T (true) if the first n characters of
-// the strings s1 and s2 are the same and logical 0 (false) otherwise.
-//
-// Input data:
-// //NUT: add description here
-//
-// Output data:
-// //NUT: add description here
-//
-// Status:
-// 16-Apr-2007 -- Nutricato Raffaele: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),3,3);
-
-res = (part(s1,1:n) == part(s2,1:n));
-endfunction
+function res = SCI2Cstrncmp(s1,s2,n) +// function res = SCI2Cstrncmp(s1,s2,n) +// ----------------------------------------------------------------- +// This function compares first n characters of strings s1 and s2. +// SCI2Cstrncmp(s1,s2,n) returns 1logical T (true) if the first n characters of +// the strings s1 and s2 are the same and logical 0 (false) otherwise. +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// Status: +// 16-Apr-2007 -- Nutricato Raffaele: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),3,3); + +res = (part(s1,1:n) == part(s2,1:n)); +endfunction diff --git a/macros/GeneralFunctions/SCI2Cstrncmps1size.sci b/macros/GeneralFunctions/SCI2Cstrncmps1size.sci index 38e8c371..909de50d 100644 --- a/macros/GeneralFunctions/SCI2Cstrncmps1size.sci +++ b/macros/GeneralFunctions/SCI2Cstrncmps1size.sci @@ -1,32 +1,32 @@ -function res = SCI2Cstrncmps1size(s1,s2);
-// function res = SCI2Cstrncmps1size(s1,s2);
-// -----------------------------------------------------------------
-// #RNU_RES_B
-// This function compares first n characters of strings s1 and s2.
-// n is the size of the string s1.
-// SCI2Cstrncmps1size returns logical T (true) if the first n characters of
-// the strings s1 and s2 are the same and logical 0 (false) otherwise.
-//
-// Input data:
-// //NUT: add description here
-//
-// Output data:
-// //NUT: add description here
-//
-// #RNU_RES_E
-// Status:
-// 16-Apr-2007 -- Nutricato Raffaele: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),2,2);
-
-n = length(s1);
-res = (part(s1,1:n) == part(s2,1:n));
-
-endfunction
+function res = SCI2Cstrncmps1size(s1,s2); +// function res = SCI2Cstrncmps1size(s1,s2); +// ----------------------------------------------------------------- +// #RNU_RES_B +// This function compares first n characters of strings s1 and s2. +// n is the size of the string s1. +// SCI2Cstrncmps1size returns logical T (true) if the first n characters of +// the strings s1 and s2 are the same and logical 0 (false) otherwise. +// +// Input data: +// //NUT: add description here +// +// Output data: +// //NUT: add description here +// +// #RNU_RES_E +// Status: +// 16-Apr-2007 -- Nutricato Raffaele: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),2,2); + +n = length(s1); +res = (part(s1,1:n) == part(s2,1:n)); + +endfunction diff --git a/macros/GeneralFunctions/SizeInByte.sci b/macros/GeneralFunctions/SizeInByte.sci index fa2d4f94..9807d180 100644 --- a/macros/GeneralFunctions/SizeInByte.sci +++ b/macros/GeneralFunctions/SizeInByte.sci @@ -1,41 +1,41 @@ -function SizeIn = SizeInByte(InDataType)
-// function SizeIn = SizeInByte(InDataType)
-// -----------------------------------------------------------------
-// #RNU_RES_B
-// Returns the size in bytes of the input data type.
-//
-// Input data:
-// InDataType: input data type. It can be:
-// 'float'
-// 'double'
-// 'floatComplex*'
-// 'doubleComplex*'
-//
-// Output data:
-// SizeIn: size in bytes of the input data type.
-//
-// #RNU_RES_E
-// Status:
-// 12-May-2007 -- Nutricato Raffaele: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),1,1);
-
-if (InDataType == 'float')
- SizeIn = 4;
-elseif (InDataType == 'double')
- SizeIn = 8;
-elseif (InDataType == 'floatComplex*')
- SizeIn = 8;
-elseif (InDataType == 'doubleComplex*')
- SizeIn = 16;
-else
- error('Unknown data type: '+InDataType);
-end
-endfunction
+function SizeIn = SizeInByte(InDataType) +// function SizeIn = SizeInByte(InDataType) +// ----------------------------------------------------------------- +// #RNU_RES_B +// Returns the size in bytes of the input data type. +// +// Input data: +// InDataType: input data type. It can be: +// 'float' +// 'double' +// 'floatComplex*' +// 'doubleComplex*' +// +// Output data: +// SizeIn: size in bytes of the input data type. +// +// #RNU_RES_E +// Status: +// 12-May-2007 -- Nutricato Raffaele: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +if (InDataType == 'float') + SizeIn = 4; +elseif (InDataType == 'double') + SizeIn = 8; +elseif (InDataType == 'floatComplex*') + SizeIn = 8; +elseif (InDataType == 'doubleComplex*') + SizeIn = 16; +else + error('Unknown data type: '+InDataType); +end +endfunction diff --git a/macros/GeneralFunctions/dispina.sci b/macros/GeneralFunctions/dispina.sci index dc07cddc..6ce3c489 100644 --- a/macros/GeneralFunctions/dispina.sci +++ b/macros/GeneralFunctions/dispina.sci @@ -1,31 +1,31 @@ -function dispina(instring);
-// function dispina(instring);
-// -----------------------------------------------------------------
-// Quista sacciu sulu iou comu funziona e a ce me serve.
-//
-// Input data:
-//
-// Output data:
-//
-// Status:
-// 12-Apr-2007 -- Nutricato Raffaele: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
+function dispina(instring); +// function dispina(instring); +// ----------------------------------------------------------------- +// Quista sacciu sulu iou comu funziona e a ce me serve. +// +// Input data: +// +// Output data: +// +// Status: +// 12-Apr-2007 -- Nutricato Raffaele: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- -// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),1,1);
-
-disp('++++++++++++++++++++++++++++++++++++++++++++++++++')
-disp('++++++++++++++++++++++++++++++++++++++++++++++++++')
-disp('++++++++++++++++++++++++++++++++++++++++++++++++++')
-disp('++++++++++++++++++++++++++++++++++++++++++++++++++')
-disp(instring);
-disp('++++++++++++++++++++++++++++++++++++++++++++++++++')
-disp('++++++++++++++++++++++++++++++++++++++++++++++++++')
-disp('++++++++++++++++++++++++++++++++++++++++++++++++++')
-disp('++++++++++++++++++++++++++++++++++++++++++++++++++')
-endfunction
+// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +disp('++++++++++++++++++++++++++++++++++++++++++++++++++') +disp('++++++++++++++++++++++++++++++++++++++++++++++++++') +disp('++++++++++++++++++++++++++++++++++++++++++++++++++') +disp('++++++++++++++++++++++++++++++++++++++++++++++++++') +disp(instring); +disp('++++++++++++++++++++++++++++++++++++++++++++++++++') +disp('++++++++++++++++++++++++++++++++++++++++++++++++++') +disp('++++++++++++++++++++++++++++++++++++++++++++++++++') +disp('++++++++++++++++++++++++++++++++++++++++++++++++++') +endfunction diff --git a/macros/GeneralFunctions/filenamefprintf.sci b/macros/GeneralFunctions/filenamefprintf.sci index de546feb..b9650eeb 100644 --- a/macros/GeneralFunctions/filenamefprintf.sci +++ b/macros/GeneralFunctions/filenamefprintf.sci @@ -1,57 +1,57 @@ -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.
-// Everytime filenamefprintf is called it
-// opens the file, prints the string in it and then closes it.
-// Opening is performed in read/append mode (at+).
-//
-// 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:
-// ---
-//
-// Status:
-// 31-Jan-2006 -- Nutricato Raffaele: Author.
-// 31-Jan-2006 -- Nutricato Raffaele: TEST OK.
-//
-// Copyright 2006 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),4,4);
-
-
-// [FidReportFile, mess] = mopen(deblank(filename),'at+');
- if type(filename) == 1 then // double
- FidReportFile = filename;
- mess = "invalid filename";
- elseif type(filename) == 10 then // string
- [FidReportFile, mess] = mopen(filename,'a+');
- else
- FidReportFile = -1;
- mess = "invalid filename type";
- end
- if (FidReportFile == -1) then
- error(9999, mess);
- end
- if formattedstring == 'n'
- mputstr(str,FidReportFile);
- else
- mfprintf(FidReportFile, str);
- end
- if ennewline=='y' then
- mfprintf(FidReportFile,'\n');
- end
- if type(filename) == 10 then
- mclose(FidReportFile);
- end
-endfunction
+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. +// Everytime filenamefprintf is called it +// opens the file, prints the string in it and then closes it. +// Opening is performed in read/append mode (at+). +// +// 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: +// --- +// +// Status: +// 31-Jan-2006 -- Nutricato Raffaele: Author. +// 31-Jan-2006 -- Nutricato Raffaele: TEST OK. +// +// Copyright 2006 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),4,4); + + +// [FidReportFile, mess] = mopen(deblank(filename),'at+'); + if type(filename) == 1 then // double + FidReportFile = filename; + mess = "invalid filename"; + elseif type(filename) == 10 then // string + [FidReportFile, mess] = mopen(filename,'a+'); + else + FidReportFile = -1; + mess = "invalid filename type"; + end + if (FidReportFile == -1) then + error(9999, mess); + end + if formattedstring == 'n' + mputstr(str,FidReportFile); + else + mfprintf(FidReportFile, str); + end + if ennewline=='y' then + mfprintf(FidReportFile,'\n'); + end + if type(filename) == 10 then + mclose(FidReportFile); + end +endfunction diff --git a/macros/GeneralFunctions/float.sci b/macros/GeneralFunctions/float.sci index 634950b1..33b8ec0a 100644 --- a/macros/GeneralFunctions/float.sci +++ b/macros/GeneralFunctions/float.sci @@ -1,26 +1,26 @@ -function y = float(x)
-// -----------------------------------------------------------------
-// Dummy function for float precision specifier.
-//
-// Input data:
-// x: input array or scalar.
-//
-// Output data:
-// y: output array or scalar.
-//
-// Status:
-// 12-Apr-2007 -- Nutricato Raffaele: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
+function y = float(x) +// ----------------------------------------------------------------- +// Dummy function for float precision specifier. +// +// Input data: +// x: input array or scalar. +// +// Output data: +// y: output array or scalar. +// +// Status: +// 12-Apr-2007 -- Nutricato Raffaele: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- -// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),1,1);
-
-
-y = x;
-
-endfunction
+// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + + +y = x; + +endfunction diff --git a/macros/GeneralFunctions/squeezestrings.sci b/macros/GeneralFunctions/squeezestrings.sci index 049476d1..a01f15ab 100644 --- a/macros/GeneralFunctions/squeezestrings.sci +++ b/macros/GeneralFunctions/squeezestrings.sci @@ -1,31 +1,31 @@ -function OutString = squeezestrings(InStringArray)
-// function OutString = squeezestrings(InStringArray)
-// -----------------------------------------------------------------
-// #RNU_RES_B
-// Converts an array of strings into a single string.
-//
-// Input data:
-// InStringArray: Array of strings.
-//
-// Output data:
-// OutString: Output string.
-//
-// #RNU_RES_E
-// Status:
-// 12-Apr-2007 -- Nutricato Raffaele: Author.
-//
-// Copyright 2007 Raffaele Nutricato.
-// Contact: raffaele.nutricato@tiscali.it
-// -----------------------------------------------------------------
-
-// ------------------------------
-// --- Check input arguments. ---
-// ------------------------------
-SCI2CNInArgCheck(argn(2),1,1);
-
-OutString = [];
-for counterstrings = 1:max(size(InStringArray))
- OutString = OutString+InStringArray(counterstrings);
-end
-
-endfunction
+function OutString = squeezestrings(InStringArray) +// function OutString = squeezestrings(InStringArray) +// ----------------------------------------------------------------- +// #RNU_RES_B +// Converts an array of strings into a single string. +// +// Input data: +// InStringArray: Array of strings. +// +// Output data: +// OutString: Output string. +// +// #RNU_RES_E +// Status: +// 12-Apr-2007 -- Nutricato Raffaele: Author. +// +// Copyright 2007 Raffaele Nutricato. +// Contact: raffaele.nutricato@tiscali.it +// ----------------------------------------------------------------- + +// ------------------------------ +// --- Check input arguments. --- +// ------------------------------ +SCI2CNInArgCheck(argn(2),1,1); + +OutString = []; +for counterstrings = 1:max(size(InStringArray)) + OutString = OutString+InStringArray(counterstrings); +end + +endfunction |