Index: /trunk/BNS/bnsoutf.cpp
===================================================================
--- /trunk/BNS/bnsoutf.cpp	(revision 853)
+++ /trunk/BNS/bnsoutf.cpp	(revision 854)
@@ -16,4 +16,5 @@
  * -----------------------------------------------------------------------*/
 
+#include <math.h>
 #include <iomanip>
 
@@ -137,4 +138,8 @@
                      const ColumnVector&) {
 
+  if (_sampl != 0 && fmod(GPSweeks, _sampl) != 0.0) {
+    return failure;
+  }
+
   QDateTime datTim = dateAndTimeFromGPSweek(GPSweek, GPSweeks);
 
Index: /trunk/BNS/bnsoutf.h
===================================================================
--- /trunk/BNS/bnsoutf.h	(revision 853)
+++ /trunk/BNS/bnsoutf.h	(revision 854)
@@ -6,4 +6,6 @@
 #include <QtCore>
 
+#include "bnsutils.h"
+
 class bnsoutf {
  public:
@@ -12,12 +14,10 @@
   virtual ~bnsoutf();
 
-  virtual void write(int GPSweek, double GPSweeks, const QString& prn, 
-                     const ColumnVector& xx);
+  virtual t_irc write(int GPSweek, double GPSweeks, const QString& prn, 
+                      const ColumnVector& xx);
 
  protected:
   virtual void writeHeader(const QDateTime& datTim) = 0;
   std::ofstream _out;
-  int           _lastGPSweek;
-  double        _lastGPSweeks;
 
  private:
Index: /trunk/BNS/bnsrinex.cpp
===================================================================
--- /trunk/BNS/bnsrinex.cpp	(revision 853)
+++ /trunk/BNS/bnsrinex.cpp	(revision 854)
@@ -42,8 +42,13 @@
 // Write One Epoch
 ////////////////////////////////////////////////////////////////////////////
-void bnsRinex::write(int GPSweek, double GPSweeks, const QString& prn, 
+t_irc bnsRinex::write(int GPSweek, double GPSweeks, const QString& prn, 
                    const ColumnVector& xx) {
 
-  bnsoutf::write(GPSweek, GPSweeks, prn, xx);
+  if (bnsoutf::write(GPSweek, GPSweeks, prn, xx) == success) {
 
+    return success;
+  }
+  else {
+    return failure;
+  }
 }
Index: /trunk/BNS/bnsrinex.h
===================================================================
--- /trunk/BNS/bnsrinex.h	(revision 853)
+++ /trunk/BNS/bnsrinex.h	(revision 854)
@@ -13,6 +13,6 @@
            const QString& intr, int sampl);
   virtual ~bnsRinex();
-  virtual void write(int GPSweek, double GPSweeks, const QString& prn, 
-                     const ColumnVector& xx);
+  virtual t_irc write(int GPSweek, double GPSweeks, const QString& prn, 
+                      const ColumnVector& xx);
 
  private:
Index: /trunk/BNS/bnssp3.cpp
===================================================================
--- /trunk/BNS/bnssp3.cpp	(revision 853)
+++ /trunk/BNS/bnssp3.cpp	(revision 854)
@@ -29,4 +29,7 @@
                const QString& intr, int sampl) 
   : bnsoutf(prep, ext, path, intr, sampl) {
+
+  _lastGPSweek  = 0;
+  _lastGPSweeks = 0.0;
 }
 
@@ -44,24 +47,30 @@
 // Write One Epoch
 ////////////////////////////////////////////////////////////////////////////
-void bnsSP3::write(int GPSweek, double GPSweeks, const QString& prn, 
+t_irc bnsSP3::write(int GPSweek, double GPSweeks, const QString& prn, 
                    const ColumnVector& xx) {
 
-  bnsoutf::write(GPSweek, GPSweeks, prn, xx);
+  if ( bnsoutf::write(GPSweek, GPSweeks, prn, xx) == success) {
 
-  if (_lastGPSweek != GPSweek || _lastGPSweeks != GPSweeks) {
-    _lastGPSweek  = GPSweek;
-    _lastGPSweeks = GPSweeks;
-
-    QDateTime datTim = dateAndTimeFromGPSweek(GPSweek, GPSweeks);
-    double sec = fmod(GPSweeks, 60.0);
-
-    _out << "*  " 
-         << datTim.toString("yyyy MM dd hh mm").toAscii().data()
-         << setw(12) << setprecision(8) << sec << endl; 
+    if (_lastGPSweek != GPSweek || _lastGPSweeks != GPSweeks) {
+      _lastGPSweek  = GPSweek;
+      _lastGPSweeks = GPSweeks;
+    
+      QDateTime datTim = dateAndTimeFromGPSweek(GPSweek, GPSweeks);
+      double sec = fmod(GPSweeks, 60.0);
+    
+      _out << "*  " 
+           << datTim.toString("yyyy MM dd hh mm").toAscii().data()
+           << setw(12) << setprecision(8) << sec << endl; 
+    }
+    _out << "P" << prn.toAscii().data()
+         << setw(14) << setprecision(6) << xx(1) / 1000.0
+         << setw(14) << setprecision(6) << xx(2) / 1000.0
+         << setw(14) << setprecision(6) << xx(3) / 1000.0
+         << setw(14) << setprecision(6) << xx(4) * 1e6 << endl;
+    
+    return success;
   }
-  _out << "P" << prn.toAscii().data()
-       << setw(14) << setprecision(6) << xx(1) / 1000.0
-       << setw(14) << setprecision(6) << xx(2) / 1000.0
-       << setw(14) << setprecision(6) << xx(3) / 1000.0
-       << setw(14) << setprecision(6) << xx(4) * 1e6 << endl;
+  else {
+    return failure;
+  }
 }
Index: /trunk/BNS/bnssp3.h
===================================================================
--- /trunk/BNS/bnssp3.h	(revision 853)
+++ /trunk/BNS/bnssp3.h	(revision 854)
@@ -13,9 +13,11 @@
          const QString& intr, int sampl);
   virtual ~bnsSP3();
-  virtual void write(int GPSweek, double GPSweeks, const QString& prn, 
-                     const ColumnVector& xx);
+  virtual t_irc write(int GPSweek, double GPSweeks, const QString& prn, 
+                      const ColumnVector& xx);
 
  private:
   virtual void writeHeader(const QDateTime& datTim);
+  int    _lastGPSweek;
+  double _lastGPSweeks;
 };
 
Index: /trunk/BNS/bnsutils.h
===================================================================
--- /trunk/BNS/bnsutils.h	(revision 853)
+++ /trunk/BNS/bnsutils.h	(revision 854)
@@ -9,4 +9,6 @@
 
 class gpsEph;
+
+enum t_irc {failure = -1, success}; // return code
 
 void expandEnvVar(QString& str);
