Index: /trunk/FACT++/src/fitsdump.cc
===================================================================
--- /trunk/FACT++/src/fitsdump.cc	(revision 11909)
+++ /trunk/FACT++/src/fitsdump.cc	(revision 11910)
@@ -14,4 +14,16 @@
 
 using namespace std;
+
+class MyColumn : public CCfits::Column
+{
+public:
+    const string &comment() const { return CCfits::Column::comment(); }
+    long width() const
+    {//the width() method seems to be buggy (or empty ?) as it always return 1... redo it ourselves.
+        string inter = format();
+        inter = inter.substr(0, inter.size()-1);
+        return atoi(inter.c_str());
+    }
+};
 
 class FitsDumper
@@ -25,5 +37,5 @@
     CCfits::FITS  *fFile;                 /// FITS pointer
     CCfits::Table *fTable;                /// Table pointer
-    map<string, CCfits::Column*> fColMap; /// map between the column names and their CCfits objects
+    map<string, MyColumn*> fColMap; /// map between the column names and their CCfits objects
 
     // Convert CCfits::ValueType into a human readable string
@@ -43,5 +55,5 @@
 
     /// Write a single row of the selected data
-    int  WriteRow(ostream &, const vector<CCfits::Column*> &, const vector<int> &, unsigned char *) const;
+    int  WriteRow(ostream &, const vector<MyColumn*> &, const vector<int> &, unsigned char *, const vector<pair<int, int> >&) const;
 
     bool OpenFile(const string &);        /// Open a file
@@ -182,11 +194,12 @@
 //!         the memory were the row has been loaded by cfitsio
 //
-int FitsDumper::WriteRow(ostream &out, const vector<CCfits::Column*> &list, const vector<int> &offsets, unsigned char* fitsBuffer) const
+int FitsDumper::WriteRow(ostream &out, const vector<MyColumn*> &list, const vector<int> &offsets, unsigned char* fitsBuffer, const vector<pair<int, int> >& ranges) const
 {
     int cnt = 0;
 
-    for (vector<CCfits::Column*>::const_iterator it=list.begin(); it!=list.end(); it++)
-    {
-        const CCfits::Column *col = *it;
+    vector<pair<int, int> >::const_iterator jt = ranges.begin();
+    for (vector<MyColumn*>::const_iterator it=list.begin(); it!=list.end(); it++, jt++)
+    {
+        const MyColumn *col = *it;
 
         // CCfits starts counting at 1 not 0
@@ -197,5 +210,5 @@
 
         // Loop over all array entries
-        for (int width=0; width<col->width(); width++)
+        for (int width=jt->first; width<jt->second; width++)
         {
             switch (col->type())
@@ -243,5 +256,5 @@
     map<int,int> sizes;
 
-    for (map<string, CCfits::Column*>::const_iterator it=fColMap.begin();
+    for (map<string, MyColumn*>::const_iterator it=fColMap.begin();
          it!=fColMap.end(); it++)
     {
@@ -325,5 +338,10 @@
     }
 
-    fColMap = fTable->column();
+    map<string, CCfits::Column*>& tCols = fTable->column();
+    for (map<string, CCfits::Column*>::const_iterator it = tCols.begin(); it != tCols.end(); it++)
+    {
+        fColMap.insert(make_pair(it->first, static_cast<MyColumn*>(it->second)));
+    }
+//    fColMap = fTable->column();
 
     fTable->makeThisCurrent();
@@ -336,9 +354,4 @@
 }
 
-class MyColumn : public CCfits::Column
-{
-public:
-    const string &comment() const { return CCfits::Column::comment(); }
-};
 
 void FitsDumper::List()
@@ -358,7 +371,15 @@
         CCfits::Table *table = dynamic_cast<CCfits::Table*>(extMap.find(it->first)->second);
 
+        table->makeThisCurrent();
+        table->readData();
+
         cout << " " << it->first << " [" << table->rows() << "]\n";
 
         const map<string, CCfits::Column*> &cols = table->column();
+
+//        for (map<string, CCfits::Column*>::const_iterator id = cols.begin(); ib != cols.end(); ib++)
+//        {
+//            TFORM
+//        }
 
         for (map<string, CCfits::Column*>::const_iterator ic=cols.begin();
@@ -492,8 +513,37 @@
 
     // Loop over all columns in our list of requested columns
-    vector<CCfits::Column*> columns;
+    vector<MyColumn*> columns;
+    vector<pair<int, int> > ranges;
     for (vector<string>::const_iterator it=list.begin(); it!=list.end(); it++)
-        columns.push_back(fColMap.find(*it)->second);
-
+    {
+        MyColumn *cCol = static_cast<MyColumn*>(fColMap.find(*it)->second);
+        //CCfits::Column* cCol = fColMap.find(*it)->second;
+        columns.push_back(cCol);
+        int start, end;
+        if (cCol->width() != 1)
+        {//get the desired range of that column to output
+            cout << "Column " << *it << " has " << cCol->width() << " entries. Please tell us which of them should be outputted. " << endl;
+            cout << "Please enter the first value to dump (min 0, max " << cCol->width()-1 << "): ";
+            cin >> start;
+            while (start < 0 || start > cCol->width()-1)
+            {
+                cout << "value invalid. Please stick to the range 0-" << cCol->width()-1 << ": ";
+                cin >> start;
+            }
+            cout << "Please enter the last value to dump (min " << start << ", max " << cCol->width()-1 << "): ";
+            cin >> end;
+            while (end < start || end > cCol->width()-1)
+            {
+                cout << "value invalid. Please stick to the range " << start << "-" << cCol->width()-1 << ": ";
+                cin >> end;
+            }
+            end++;
+            ranges.push_back(make_pair(start, end));
+        }
+        else
+        {
+            ranges.push_back(make_pair(0, cCol->width()));
+        }
+    }
 
     const int size = offsets[offsets.size()-1];
@@ -509,5 +559,5 @@
             break;
         }
-        if (WriteRow(out, columns, offsets, fitsBuffer)<0)
+        if (WriteRow(out, columns, offsets, fitsBuffer, ranges)<0)
         {
             status=1;
@@ -623,4 +673,9 @@
     if (conf.Has("outfile"))
     {
+        if (!conf.Has("col"))
+        {
+            cout << "Please specify the columns that should be dumped as arguments. Aborting" << endl;
+            return 0;
+        }
         if (!Dump(conf.Get<string>("outfile"),
                   conf.Get<vector<string>>("col"),
