diff options
author | yash1112 | 2017-07-07 21:20:49 +0530 |
---|---|---|
committer | yash1112 | 2017-07-07 21:20:49 +0530 |
commit | 3f52712f806fbd80d66dfdcaff401e5cf94dcca4 (patch) | |
tree | a8333b8187cb44b505b9fe37fc9a7ac8a1711c10 /macros/GeneralFunctions/File2StringArray.sci | |
download | Scilab2C_fossee_old-3f52712f806fbd80d66dfdcaff401e5cf94dcca4.tar.gz Scilab2C_fossee_old-3f52712f806fbd80d66dfdcaff401e5cf94dcca4.tar.bz2 Scilab2C_fossee_old-3f52712f806fbd80d66dfdcaff401e5cf94dcca4.zip |
sci2c arduino updated
Diffstat (limited to 'macros/GeneralFunctions/File2StringArray.sci')
-rw-r--r-- | macros/GeneralFunctions/File2StringArray.sci | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/macros/GeneralFunctions/File2StringArray.sci b/macros/GeneralFunctions/File2StringArray.sci new file mode 100644 index 0000000..626cb6c --- /dev/null +++ b/macros/GeneralFunctions/File2StringArray.sci @@ -0,0 +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
+// -----------------------------------------------------------------
+ +// ------------------------------
+// --- 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
|