summaryrefslogtreecommitdiff
path: root/2.3-1/macros/SymbolTable/ST_MatchSymbol.sci
diff options
context:
space:
mode:
authorSiddhesh Wani2015-05-25 14:46:31 +0530
committerSiddhesh Wani2015-05-25 14:46:31 +0530
commit6a320264c2de3d6dd8cc1d1327b3c30df4c8cb26 (patch)
tree1b7bd89fdcfd01715713d8a15db471dc75a96bbf /2.3-1/macros/SymbolTable/ST_MatchSymbol.sci
downloadScilab2C-6a320264c2de3d6dd8cc1d1327b3c30df4c8cb26.tar.gz
Scilab2C-6a320264c2de3d6dd8cc1d1327b3c30df4c8cb26.tar.bz2
Scilab2C-6a320264c2de3d6dd8cc1d1327b3c30df4c8cb26.zip
Original Version
Diffstat (limited to '2.3-1/macros/SymbolTable/ST_MatchSymbol.sci')
-rw-r--r--2.3-1/macros/SymbolTable/ST_MatchSymbol.sci70
1 files changed, 70 insertions, 0 deletions
diff --git a/2.3-1/macros/SymbolTable/ST_MatchSymbol.sci b/2.3-1/macros/SymbolTable/ST_MatchSymbol.sci
new file mode 100644
index 00000000..20f0bbe8
--- /dev/null
+++ b/2.3-1/macros/SymbolTable/ST_MatchSymbol.sci
@@ -0,0 +1,70 @@
+function [TBFlagfound,TBFlagEqualSymbols] = ST_MatchSymbol(TBName,TBType,TBSize,TBValue,TBFindLike,TBDimension,SymbolTableFileName,MatchRule)
+// function [TBFlagfound,TBFlagEqualSymbols] = ST_MatchSymbol(TBName,TBType,TBSize,TBValue,TBFindLike,TBDimension,SymbolTableFileName,MatchRule)
+// -----------------------------------------------------------------
+// Match function for the symbol table.
+//
+// Input data:
+// MatchRule: can be 'all','type','size','none'
+// //NUT: add description here
+//
+// Output data:
+// TBFlagfound: 0 = if the symbol doesn't exits.
+// 1 = the symbol exits.
+// 2 = the symbol exists but it is a non-initialized global variable.
+// TBFlagEqualSymbols: 0 if the two symbols don't have the same settings,
+// 1 if the two symbols have the same settings.
+//
+// Status:
+// 26-Oct-2007 -- Raffaele Nutricato: Author.
+// 26-Oct-2007 -- Alberto Morea: Test Ok.
+//
+// Copyright 2007 Raffaele Nutricato & Alberto Morea.
+// Contact: raffaele.nutricato@tiscali.it
+// -----------------------------------------------------------------
+
+
+// ------------------------------
+// --- Check input arguments. ---
+// ------------------------------
+SCI2CNInArgCheck(argn(2),8,8);
+
+TBFlagfound = 0;
+TBFlagEqualSymbols = 0;
+
+// --- Find symbol (If exists). ---
+[TBFlagfound,tmpType,tmpSize,tmpValue,tmpFindLike,tmpDimension] = ...
+ ST_Get(TBName,SymbolTableFileName);
+
+if (TBFlagfound == 1)
+ if (tmpType == 'GBLToBeDefined')
+ TBFlagfound = 2;
+ TBFlagEqualSymbols = 0; // I don't want to force the error issue in ST_InsOutArg.sci
+ else
+ // Symbol already exists. Check that it has the same settings of the current output argument.
+ TBFlagEqualSymbols = 1;
+ if (MatchRule == 'type' | MatchRule == 'all')
+ if (mtlb_strcmp(tmpType,TBType) == %F)
+ TBFlagEqualSymbols = 0;
+ end
+ end
+ if (MatchRule == 'size' | MatchRule == 'all')
+ // First check the dimension.
+ if (tmpDimension ~= TBDimension)
+ TBFlagEqualSymbols = 0;
+ end
+ // Then if the size is a number also its value is compared.
+ if (isnum(tmpSize(1))) & (isnum(TBSize(1)))
+ if (mtlb_strcmp(tmpSize(1),TBSize(1)) == %F)
+ TBFlagEqualSymbols = 0;
+ end
+ end
+ if (isnum(tmpSize(2))) & (isnum(TBSize(2)))
+ if (mtlb_strcmp(tmpSize(2),TBSize(2)) == %F)
+ TBFlagEqualSymbols = 0;
+ end
+ end
+ end
+ end
+end
+
+endfunction