Index: molecuilder/src/periodentafel.cpp
===================================================================
--- molecuilder/src/periodentafel.cpp	(revision 941b662597fb3178f5bc2a0b4271287687248078)
+++ molecuilder/src/periodentafel.cpp	(revision b021e43e913f23b6e170837b80c0566047ae49a4)
@@ -161,111 +161,142 @@
 /** Loads element list from file.
  */
-bool periodentafel::LoadPeriodentafel()
+bool periodentafel::LoadPeriodentafel(char *filename)
 {
   ifstream infile;
   double tmp;
   element *ptr;
+  bool status = true;
+  bool otherstatus = true;
   
   // fill elements DB
-  infile.open("elements.db");
-  infile.getline(header1, 255);
-  infile.getline(header2, 255); // skip first two header lines
-  while (!infile.eof()) {
-    element *neues = new element;
-    infile >> neues->name;
-    //infile >> ws;
-    infile >> neues->symbol;
-    //infile >> ws;
-    infile >> neues->period;
-    //infile >> ws;
-    infile >> neues->group;
-    //infile >> ws;
-    infile >> neues->block;
-    //infile >> ws;
-    infile >> neues->Z;
-    //infile >> ws;
-    infile >> neues->mass;
-    //infile >> ws;
-    infile >> neues->CovalentRadius;
-    //infile >> ws;
-    infile >> neues->VanDerWaalsRadius;
-    //infile >> ws;
-    periodentafel::AddElement(neues);
-    infile >> ws;
-    //neues->Output((ofstream *)&cout);
-  }
-  infile.close();
-  infile.clear();
+  if (filename == NULL)
+    infile.open("elements.db");
+  else
+    infile.open(filename);
+  if (infile != NULL) {
+    infile.getline(header1, 255);
+    infile.getline(header2, 255); // skip first two header lines
+    cout <<  "Parsed elements:";
+    while (!infile.eof()) {
+      element *neues = new element;
+      infile >> neues->name;
+      //infile >> ws;
+      infile >> neues->symbol;
+      //infile >> ws;
+      infile >> neues->period;
+      //infile >> ws;
+      infile >> neues->group;
+      //infile >> ws;
+      infile >> neues->block;
+      //infile >> ws;
+      infile >> neues->Z;
+      //infile >> ws;
+      infile >> neues->mass;
+      //infile >> ws;
+      infile >> neues->CovalentRadius;
+      //infile >> ws;
+      infile >> neues->VanDerWaalsRadius;
+      //infile >> ws;
+      periodentafel::AddElement(neues);
+      infile >> ws;
+      cout << " " << neues->symbol;
+      //neues->Output((ofstream *)&cout);
+    }
+    cout << endl;
+    infile.close();
+    infile.clear();
+  } else
+    status = false;
 
   // fill valence DB per element
   infile.open("valence.db");
-  while (!infile.eof()) {
-  	infile >> tmp;
-  	infile >> ws;
-  	infile >> FindElement((int)tmp)->Valence;
-  	infile >> ws;
-  	//cout << Verbose(3) << "Element " << (int)tmp << " has " << find_element((int)tmp)->Valence << " valence electrons." << endl;
-  }
-  infile.close();
-  infile.clear();
+  if (infile != NULL) {
+    while (!infile.eof()) {
+    	infile >> tmp;
+    	infile >> ws;
+    	infile >> FindElement((int)tmp)->Valence;
+    	infile >> ws;
+    	//cout << Verbose(3) << "Element " << (int)tmp << " has " << find_element((int)tmp)->Valence << " valence electrons." << endl;
+    }
+    infile.close();
+    infile.clear();
+  } else
+    otherstatus = false;
 
   // fill valence DB per element
   infile.open("orbitals.db");
-  while (!infile.eof()) {
-    infile >> tmp;
-    infile >> ws;
-    infile >> FindElement((int)tmp)->NoValenceOrbitals;
-    infile >> ws;
-    //cout << Verbose(3) << "Element " << (int)tmp << " has " << find_element((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
-  }
-  infile.close();
-  infile.clear();
+  if (infile != NULL) {
+    while (!infile.eof()) {
+      infile >> tmp;
+      infile >> ws;
+      infile >> FindElement((int)tmp)->NoValenceOrbitals;
+      infile >> ws;
+      //cout << Verbose(3) << "Element " << (int)tmp << " has " << find_element((int)tmp)->NoValenceOrbitals << " number of singly occupied valence orbitals." << endl;
+    }
+    infile.close();
+    infile.clear();
+  } else
+    otherstatus = false;
   
   // fill H-BondDistance DB per element
   infile.open("Hbonddistance.db");
-  while (!infile.eof()) {
-  	infile >> tmp;
-    ptr = FindElement((int)tmp);
-  	infile >> ws;
-    infile >> ptr->HBondDistance[0];
-    infile >> ptr->HBondDistance[1];
-    infile >> ptr->HBondDistance[2];
-  	infile >> ws;
-    //cout << Verbose(3) << "Element " << (int)tmp << " has " << find_element((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl;
-  }
-  infile.close();
-  infile.clear();
+  if (infile != NULL) {
+    while (!infile.eof()) {
+    	infile >> tmp;
+      ptr = FindElement((int)tmp);
+    	infile >> ws;
+      infile >> ptr->HBondDistance[0];
+      infile >> ptr->HBondDistance[1];
+      infile >> ptr->HBondDistance[2];
+    	infile >> ws;
+      //cout << Verbose(3) << "Element " << (int)tmp << " has " << find_element((int)tmp)->HBondDistance[0] << " Angstrom typical distance to hydrogen." << endl;
+    }
+    infile.close();
+    infile.clear();
+  } else
+    otherstatus = false;
   
   // fill H-BondAngle DB per element
   infile.open("Hbondangle.db");
-  while (!infile.eof()) {
-    infile >> tmp;
-    ptr = FindElement((int)tmp);
-    infile >> ws;
-    infile >> ptr->HBondAngle[0];
-    infile >> ptr->HBondAngle[1];
-    infile >> ptr->HBondAngle[2];
-    infile >> ws;
-    //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondAngle[0] << ", " << FindElement((int)tmp)->HBondAngle[1] << ", " << FindElement((int)tmp)->HBondAngle[2] << " degrees bond angle for one, two, three connected hydrogens." << endl;
-  }
-  infile.close();
-  
-  return true;
+  if (infile != NULL) {
+    while (!infile.eof()) {
+      infile >> tmp;
+      ptr = FindElement((int)tmp);
+      infile >> ws;
+      infile >> ptr->HBondAngle[0];
+      infile >> ptr->HBondAngle[1];
+      infile >> ptr->HBondAngle[2];
+      infile >> ws;
+      //cout << Verbose(3) << "Element " << (int)tmp << " has " << FindElement((int)tmp)->HBondAngle[0] << ", " << FindElement((int)tmp)->HBondAngle[1] << ", " << FindElement((int)tmp)->HBondAngle[2] << " degrees bond angle for one, two, three connected hydrogens." << endl;
+    }
+    infile.close();
+  } else
+    otherstatus = false;
+  
+  return status;
 };
 
 /** Stores element list to file.
  */
-bool periodentafel::StorePeriodentafel() const
+bool periodentafel::StorePeriodentafel(char *filename) const
 {
   bool result = true;
-  ofstream f("elements.db");
-  f << header1 << endl;
-  f << header2 << endl;
-  element *walker = periodentafel::start;
-  while (walker->next != periodentafel::end) {
-    walker = walker->next;
-    result = result && walker->Output(&f);
-  }
-  f.close();
+  ofstream f;
+  
+  if (filename == NULL)
+    f.open("elements.db");
+  else
+    f.open(filename);
+  if (f != NULL) {
+    f << header1 << endl;
+    f << header2 << endl;
+    element *walker = periodentafel::start;
+    while (walker->next != periodentafel::end) {
+      walker = walker->next;
+      result = result && walker->Output(&f);
+    }
+    f.close();
+  } else
+    result = false;
   return result;
 };
