Index: /trunk/MagicSoft/Mars/Changelog
===================================================================
--- /trunk/MagicSoft/Mars/Changelog	(revision 9038)
+++ /trunk/MagicSoft/Mars/Changelog	(revision 9039)
@@ -40,4 +40,15 @@
    * mjobs/MJCalibrateSignal.cc:
      - changed again the wrong names of the tasklists
+
+   * mjobs/MSequence.[h,cc]:
+     - set default telescope to 1 so that reading old sequence files
+       gives valid sequences.
+     - overwrote Read to allow reading also old sequences which
+       have no default name in the files
+     - removed output of "DataPath" from Print
+
+   * msql/MSQLMagic.[h,cc]:
+     - added a second InsertUpdate
+     - added ExistRow
 
 
Index: /trunk/MagicSoft/Mars/mbase/MStatusArray.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MStatusArray.cc	(revision 9038)
+++ /trunk/MagicSoft/Mars/mbase/MStatusArray.cc	(revision 9039)
@@ -44,5 +44,6 @@
 #include "MStatusArray.h"
 
-#include <TH1.h>       // TH1::AddDirectoryStatus();
+#include <TH1.h>              // TH1::AddDirectoryStatus();
+#include <TFile.h>            // gFile
 #include <TClass.h>
 #include <TCanvas.h>
@@ -344,8 +345,17 @@
     Delete();
 
+    const TString keyname = name?name:"MStatusDisplay";
+
+    // Check if key exists (to suppress an error on the console
+    if (!gDirectory->GetListOfKeys()->FindObject(keyname))
+    {
+        gLog << inf << keyname << " [MStatusArray] not found." << endl;
+        return 0;
+    }
+
     // Make sure newly read histograms are not added to the current directory
     const Bool_t store = TH1::AddDirectoryStatus();
     TH1::AddDirectory(kFALSE);
-    const Int_t rc = TObjArray::Read(name?name:"MStatusDisplay");
+    const Int_t rc = TObjArray::Read(keyname);
     TH1::AddDirectory(store);
 
Index: /trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc
===================================================================
--- /trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 9038)
+++ /trunk/MagicSoft/Mars/mbase/MStatusDisplay.cc	(revision 9039)
@@ -2239,4 +2239,5 @@
                 list.Add(new TNamed(GetName(), GetTitle()));
 
+            c->SetTitle(gFile->GetName());
             list.Add(c);
         }
@@ -2246,5 +2247,5 @@
         if (list.GetEntries()==0)
         {
-            *fLog << warn << "MStatusDisplay::Read: No objects read." << endl;
+            *fLog << warn << "MStatusDisplay::Read: No objects read from " << gFile->GetName() << endl;
             return 0;
         }
Index: /trunk/MagicSoft/Mars/mjobs/MSequence.cc
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 9038)
+++ /trunk/MagicSoft/Mars/mjobs/MSequence.cc	(revision 9039)
@@ -1394,6 +1394,6 @@
     }
 
-    if (!fDataPath.IsNull())
-        out << endl << pre << "DataPath: " << fDataPath << endl;
+//    if (!fDataPath.IsNull())
+//        out << endl << pre << "DataPath: " << fDataPath << endl;
 
     if (!str.IsNull())
@@ -1512,4 +1512,32 @@
 
     fPeriod = fNight.GetMagicPeriod();
+}
+
+// --------------------------------------------------------------------------
+//
+// Read a sequence from gDirectory. If the default is given we try
+// to find a sequence with name GetName. If a key with name name
+// exists in the file read this key. Otherwise loop over all keys
+// and return the first key matching the TPRegex (regular expression)
+// matching defined by the argument.
+//
+Int_t MSequence::Read(const char *name)
+{
+    if (!name || !gFile)
+        return MParContainer::Read(name);
+
+    if (!gDirectory->GetListOfKeys()->FindObject(name))
+        return MParContainer::Read(name);
+
+    TPRegexp regexp(name);
+
+    TIter NextK(gDirectory->GetListOfKeys());
+    TObject *key = 0;
+    while ((key=NextK()))
+        if (TString(key->GetName())(regexp)==key->GetName())
+            return MParContainer::Read(key->GetName());
+
+    *fLog << warn << "WARNING - No key in " << gDirectory->GetName() << " matching " << name << "." << endl;
+    return 0;
 }
 
Index: /trunk/MagicSoft/Mars/mjobs/MSequence.h
===================================================================
--- /trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 9038)
+++ /trunk/MagicSoft/Mars/mjobs/MSequence.h	(revision 9039)
@@ -131,5 +131,5 @@
 
 public:
-    MSequence() : fTelescope(0), fSequence((UInt_t)-1), fLastRun((UInt_t)-1),
+    MSequence() : fTelescope(1), fSequence((UInt_t)-1), fLastRun((UInt_t)-1),
         fNumEvents((UInt_t)-1), fPeriod((UInt_t)-1), fLightCondition(kNA), fMonteCarlo(kFALSE)
     {
@@ -158,4 +158,5 @@
 
     // I/O
+    Int_t  Read(const char *name=0);
     Bool_t ReadDatabase(TString sql, UInt_t seq=0, UShort_t tel=0);
     Bool_t ReadFile(const char *filename, UInt_t id=(UInt_t)-1);
Index: /trunk/MagicSoft/Mars/msql/MSQLMagic.cc
===================================================================
--- /trunk/MagicSoft/Mars/msql/MSQLMagic.cc	(revision 9038)
+++ /trunk/MagicSoft/Mars/msql/MSQLMagic.cc	(revision 9039)
@@ -195,5 +195,8 @@
 Bool_t MSQLMagic::ExistStr(const char *column, const char *table, const char *test, const char *where)
 {
-    TString query(Form("SELECT %s FROM %s WHERE %s='%s' %s %s", column, table, column, test, where?"AND":"", where?where:""));
+    TString query = test ?
+        Form("SELECT %s FROM %s WHERE %s='%s' %s %s", column, table, column, test, where?"AND":"", where?where:"") :
+        Form("SELECT %s FROM %s WHERE %s", column, table, where);
+
     TSQLResult *res = Query(query);
     if (!res)
@@ -211,4 +214,14 @@
     delete res;
     return rc;
+}
+
+// --------------------------------------------------------------------------
+//
+// Check if at least one row with one field exists in table
+// defined by where
+//
+Bool_t MSQLMagic::ExistRow(const char *table, const char *where)
+{
+    return ExistStr("*", table, 0, where);
 }
 
@@ -306,4 +319,17 @@
 // --------------------------------------------------------------------------
 //
+// An abbreviation for checking whether a row with the condition where
+// exists. If no such row exist Insert vars into table, otherwise update
+// vars in table at row(s) defined by where.
+//
+Int_t MSQLMagic::InsertUpdate(const char *table, const char *vars, const char *where)
+{
+    return ExistRow(table, where) ?
+        Update(table, vars, where) :
+        Insert(table, vars);
+}
+
+// --------------------------------------------------------------------------
+//
 // An abbreviation for a Dalete-Query.
 //
Index: /trunk/MagicSoft/Mars/msql/MSQLMagic.h
===================================================================
--- /trunk/MagicSoft/Mars/msql/MSQLMagic.h	(revision 9038)
+++ /trunk/MagicSoft/Mars/msql/MSQLMagic.h	(revision 9039)
@@ -45,4 +45,5 @@
     Int_t   QueryKeyOf(const char *col, const char *ext, const char *val);
     Bool_t  ExistStr(const char *column, const char *table, const char *test, const char *where=0);
+    Bool_t  ExistRow(const char *table, const char *where);
 
     Int_t Insert(const char *table, const char *vars, const char *where=0);
@@ -50,4 +51,5 @@
     Int_t Delete(const char *table, const char *where);
     Int_t InsertUpdate(const char *table, const char *col, const char *val, const char *vars);
+    Int_t InsertUpdate(const char *table, const char *vars, const char *where);
 
     void Delete(const Option_t *o) { TObject::Delete(o); }
Index: /trunk/MagicSoft/Mars/showplot.cc
===================================================================
--- /trunk/MagicSoft/Mars/showplot.cc	(revision 9038)
+++ /trunk/MagicSoft/Mars/showplot.cc	(revision 9039)
@@ -199,5 +199,5 @@
     //
     const TString kInput = InflatePath(arg);
-    const TString kTitle = kInput.IsNull() ? kInput + "..."  : kInput;
+    const TString kTitle = kInput.IsNull() ? arg.GetArgumentStr(0) + "..."  : kInput;
 
     //
