summaryrefslogtreecommitdiff
path: root/2.3-1/macros/GeneralFunctions/File2StringArray.sci
diff options
context:
space:
mode:
authoryash11122017-07-07 21:20:49 +0530
committeryash11122017-07-07 21:20:49 +0530
commit9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 (patch)
treef50d6e06d8fe6bc1a9053ef10d4b4d857800ab51 /2.3-1/macros/GeneralFunctions/File2StringArray.sci
downloadScilab2C-9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0.tar.gz
Scilab2C-9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0.tar.bz2
Scilab2C-9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0.zip
sci2c arduino updated
Diffstat (limited to '2.3-1/macros/GeneralFunctions/File2StringArray.sci')
-rw-r--r--2.3-1/macros/GeneralFunctions/File2StringArray.sci54
1 files changed, 54 insertions, 0 deletions
diff --git a/2.3-1/macros/GeneralFunctions/File2StringArray.sci b/2.3-1/macros/GeneralFunctions/File2StringArray.sci
new file mode 100644
index 00000000..626cb6ce
--- /dev/null
+++ b/2.3-1/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