summaryrefslogtreecommitdiff
path: root/src/Scilab2C/GeneralFunctions/ReadStringCard.sci
diff options
context:
space:
mode:
authorpmarecha2008-06-05 08:49:05 +0000
committerpmarecha2008-06-05 08:49:05 +0000
commit42659d6cdbe63972aea27baf0289db8fcc1310fa (patch)
tree05cc1eb42b985cf657be112ae5a2e842a13c2126 /src/Scilab2C/GeneralFunctions/ReadStringCard.sci
parentc4ca26eb9d2bbe224e41fc40658279cb865c48fc (diff)
downloadscilab2c-42659d6cdbe63972aea27baf0289db8fcc1310fa.tar.gz
scilab2c-42659d6cdbe63972aea27baf0289db8fcc1310fa.tar.bz2
scilab2c-42659d6cdbe63972aea27baf0289db8fcc1310fa.zip
SVN is not FTP !
Diffstat (limited to 'src/Scilab2C/GeneralFunctions/ReadStringCard.sci')
-rw-r--r--src/Scilab2C/GeneralFunctions/ReadStringCard.sci51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/Scilab2C/GeneralFunctions/ReadStringCard.sci b/src/Scilab2C/GeneralFunctions/ReadStringCard.sci
new file mode 100644
index 00000000..a6abfcb7
--- /dev/null
+++ b/src/Scilab2C/GeneralFunctions/ReadStringCard.sci
@@ -0,0 +1,51 @@
+function cardvalue = ReadStringCard(filename,cardname,commentdelim,enableerror);
+// function cardvalue = ReadStringCard(filename,cardname,commentdelim,enableerror);
+// -----------------------------------------------------------------
+// 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.
+//
+// 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.
+// -----------------------------------------------------------------
+
+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
+ SCI2Cerror([cardname,' not found']);
+ else
+ warning([cardname,' not found']);
+ end
+end
+
+endfunction