diff options
author | yash1112 | 2017-07-07 21:20:49 +0530 |
---|---|---|
committer | yash1112 | 2017-07-07 21:20:49 +0530 |
commit | 9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0 (patch) | |
tree | f50d6e06d8fe6bc1a9053ef10d4b4d857800ab51 /2.3-1/macros/GeneralFunctions/ReadStringCard.sci | |
download | Scilab2C-9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0.tar.gz Scilab2C-9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0.tar.bz2 Scilab2C-9e5793a7b05b23e6044a6d7a9ddd5db39ba375f0.zip |
sci2c arduino updated
Diffstat (limited to '2.3-1/macros/GeneralFunctions/ReadStringCard.sci')
-rw-r--r-- | 2.3-1/macros/GeneralFunctions/ReadStringCard.sci | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/2.3-1/macros/GeneralFunctions/ReadStringCard.sci b/2.3-1/macros/GeneralFunctions/ReadStringCard.sci new file mode 100644 index 00000000..a4525d90 --- /dev/null +++ b/2.3-1/macros/GeneralFunctions/ReadStringCard.sci @@ -0,0 +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
+// -----------------------------------------------------------------
+ +// ------------------------------
+// --- 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
|