Index: rtol/source/tolRlink.cpp
===================================================================
--- rtol/source/tolRlink.cpp	(revision 0463dc72bd72a43b8f91c4c8f7b510958d2b1754)
+++ rtol/source/tolRlink.cpp	(revision a53fb9c4e9a7d3dbd49a06461722c2b508547bcf)
@@ -195,5 +195,5 @@
 
 //----------------------------------------------------------------------------
-extern "C" DLLEXPORT(void) RTolSetReal(char **name, int *type, double *value)
+extern "C" DLLEXPORT(void) RTolSetReal(char **name, int *type, double *value, int *ok)
 //----------------------------------------------------------------------------
 {
@@ -215,9 +215,14 @@
     BList* aux = NIL;
     LstFastAppend(result, aux, so);
-  }
-}
-
-//----------------------------------------------------------------------------
-extern "C" DLLEXPORT(void) RTolSetText(char **name, char **value)
+    R_concat(&R_stack, result);    
+    *ok = 1;
+  }
+  else {
+    *ok = 0;
+  }
+}
+
+//----------------------------------------------------------------------------
+extern "C" DLLEXPORT(void) RTolSetText(char **name, char **value, int *ok)
 //----------------------------------------------------------------------------
 {
@@ -230,9 +235,14 @@
     BList* aux = NIL;
     LstFastAppend(result, aux, so);
-  }
-}
-
-//----------------------------------------------------------------------------
-extern "C" DLLEXPORT(void) RTolSetDate(char **name, int *type, double *value)
+    R_concat(&R_stack, result);    
+    *ok = 1;
+  }
+  else {
+    *ok = 0;
+  }
+}
+
+//----------------------------------------------------------------------------
+extern "C" DLLEXPORT(void) RTolSetDate(char **name, int *type, double *value, int *ok)
 //----------------------------------------------------------------------------
 {
@@ -243,7 +253,7 @@
     d.PutIndex(*value);
   } else if(*type == 2) {
+    d.PutIndex(219147); // End
+  } else if(*type == 3) {
     d.PutIndex(-115782); // Begin
-  } else if(*type == 3) {
-    d.PutIndex(219147); // End
   } else { // type 1
     d.PutIndex(-300000); // Unknown
@@ -254,7 +264,51 @@
     BList* aux = NIL;
     LstFastAppend(result, aux, so);
-  }
-}
-
-//////////////////////////////////////////////////////////////////////////////
-
+    R_concat(&R_stack, result);    
+    *ok = 1;
+  }
+  else {
+    *ok = 0;
+  }
+}
+
+//----------------------------------------------------------------------------
+extern "C" DLLEXPORT(void) RTolSetMatrix(char **name, int *rows, int *cols, 
+  bool *mask, int *type, double *value, int *ok)
+//----------------------------------------------------------------------------
+{
+  if(TOLHasBeenInitialized()==0) RInitTolKernel();
+  char* str_name = (char*)*name;
+  BMat d(*rows, *cols);
+  for (int c=0; c< (*cols); ++c) {   
+    for (int r=0; r< (*rows); ++r) {
+      int p = c * (*rows) + r;
+      if(*mask) {
+        if(type[p] == 0) {
+          d(r, c).PutValue(value[p]);
+        } else if(type[p] == 2) {
+          d(r, c).PutValue(BDat::PosInf());
+        } else if(type[p] == 3) {
+          d(r, c).PutValue(BDat::NegInf());
+        } else { // type 1
+          d(r, c).PutKnown(BUNKNOWN);
+        }
+      } else {
+        d(r, c).PutValue(value[p]);
+      }
+    }
+  }
+  BSyntaxObject * so = new BContensMat(str_name, d, "");
+  if (so) {
+    BList* result = NIL;
+    BList* aux = NIL;
+    LstFastAppend(result, aux, so);
+    R_concat(&R_stack, result);    
+    *ok = 1;
+  }
+  else {
+    *ok = 0;
+  }
+}
+
+//////////////////////////////////////////////////////////////////////////////
+
