Index: trunk/src/lib/shell/shell_command.cc
===================================================================
--- trunk/src/lib/shell/shell_command.cc	(revision 5202)
+++ trunk/src/lib/shell/shell_command.cc	(revision 5203)
@@ -385,9 +385,11 @@
 
 
-  long classID;                    //< the classID retrieved from the Class.
-  tList<BaseObject>* objectList;   //< the list of Objects stored in classID
-  BaseObject* objectPointer;       //< a pointer to th Object to Execute the command on
-  bool emptyComplete = false;      //< if the completion input is empty string. e.g ""
-//  long completeType = SHELLC_NONE; //< the Type we'd like to complete.
+  long classID = CL_NULL;                 //< the classID retrieved from the Class.
+  ShellCommandClass* commandClass = NULL; //< the command class this command applies to.
+  tList<BaseObject>* objectList = NULL;   //< the list of Objects stored in classID
+  BaseObject* objectPointer = NULL;       //< a pointer to th Object to Execute the command on
+  bool emptyComplete = false;             //< if the completion input is empty string. e.g ""
+  unsigned int fktPos = 1;                //< the position of the function (needed for finding it)
+//  long completeType = SHELLC_NONE;      //< the Type we'd like to complete.
   SubString inputSplits(executionString, true);
 
@@ -420,93 +422,74 @@
       delete itAL;
     }
-
-  }
-
-
-   //
-//   tIterator<ShellCommandBase>* iterator = ShellCommandBase::commandList->getIterator();
-//   ShellCommandBase* elem = iterator->firstElement();
-//   while(elem != NULL)
-//   {
-//     printf("%s::%s\n", elem->className, elem->getName());
-//     if (!strncasecmp (executionString, elem->className, strlen(elem->className)) &&
-//          (*(executionString+strlen(elem->className)) == ' ' ||
-//           *(executionString+strlen(elem->className)) == ':' ))
-//     {
-//       const char* commandBegin = executionString + strlen(elem->className);
-//
-//       PRINTF(4)("Class %s matches\n", elem->className);
-//       BaseObject* objectPointer = NULL;
-//       if (ClassList::StringToID(elem->className) & CL_MASK_SINGLETON == CL_MASK_SINGLETON)
-//       {
-//         while(*commandBegin == ' ')
-//           commandBegin++;
-//         if (strncmp (commandBegin, elem->getName(), strlen(elem->getName())) ||
-//             *(commandBegin + strlen(elem->getName())) != ' ' &&
-//             *(commandBegin + strlen(elem->getName())) != '\0')
-//         {
-//           elem = iterator->nextElement();
-//           continue;
-//         }
-//         PRINTF(4)("Command %s matches\n", elem->getName());
-//         // getting singleton-reference
-//         tList<BaseObject>* list =  ClassList::getList(elem->className);
-//         if (list != NULL)
-//           objectPointer = list->firstElement();
-//       }
-//       else
-//       {
-//         // checking for the Object
-//         while(*commandBegin == ' ')
-//           commandBegin++;
-//         tList<BaseObject>* list = ClassList::getList(elem->className);
-//         if (list == NULL)
-//           break;
-//         tIterator<BaseObject>* iterBO = list->getIterator();
-//         BaseObject* enumBO = iterBO->firstElement();
-//         while(enumBO != NULL)
-//         {
-//           if(!strncmp(commandBegin, enumBO->getName(), strlen(enumBO->getName())))
-//           {
-//             PRINTF(4)("Object %s matches\n", enumBO->getName());
-//             objectPointer = enumBO;
-//             break;
-//           }
-//           enumBO = iterBO->nextElement();
-//         }
-//         delete iterBO;
-//
-//         // break on no object Found. We cannot operate on Classes, but on Objects
-//         if (objectPointer == NULL)
-//           break;
-//         commandBegin = commandBegin + strlen(objectPointer->getName());
-//         while(*commandBegin == ' ')
-//           commandBegin++;
-//         // checking for the requested function.
-//         if (strncmp (commandBegin, elem->getName(), strlen(elem->getName())))
-//         {
-//           elem = iterator->nextElement();
-//           continue;
-//         }
-//         PRINTF(4)("Function '%s' found\n", commandBegin);
-//       }
-//       const char* paramBegin = strchr(commandBegin, ' ');
-//       if (paramBegin == NULL)
-//         paramBegin = commandBegin + strlen(elem->getName());
-//       while (*paramBegin == ' ')
-//         paramBegin++;
-//
-//       PRINTF(3)("Parameters to Pass: %s\n", paramBegin);
-//       if (objectPointer != NULL && paramBegin != NULL)
-//       {
-//         elem->executeCommand(objectPointer, paramBegin);
-//         delete iterator;
-//         return true;
-//       }
-//     }
-//     elem = iterator->nextElement();
-//   }
-//   delete iterator;
-//   return true;
+    // looking for a Matching Class
+    if (likely(ShellCommandClass::commandClassList != NULL))
+    {
+      tIterator<ShellCommandClass>* itCL = ShellCommandClass::commandClassList->getIterator();
+      ShellCommandClass* elemCL = itCL->firstElement();
+      while(elemCL != NULL)
+      {
+        if (elemCL->getName() && !strcasecmp(inputSplits.getString(0), elemCL->getName()))
+        {
+          //elemCL->getName();
+          classID = ClassList::StringToID(elemCL->getName());
+          commandClass = elemCL;
+          objectList = ClassList::getList(classID);
+          break;
+        }
+        elemCL = itCL->nextElement();
+      }
+      delete itCL;
+    }
+
+
+    if (classID != CL_NULL && inputSplits.getCount() >= 2 && objectList != NULL)
+    {
+      // Checking for a Match in the Objects of classID (else take the first)
+      tIterator<BaseObject>* itBO = objectList->getIterator();
+      BaseObject* enumBO = itBO->firstElement();
+      while(enumBO)
+      {
+        if (enumBO->getName() != NULL && !strcasecmp(enumBO->getName(), inputSplits.getString(1)))
+        {
+          objectPointer = enumBO;
+          fktPos++;
+          break;
+        }
+        enumBO = itBO->nextElement();
+      }
+      delete itBO;
+
+      //
+      if (objectPointer == NULL)
+        objectPointer = objectList->firstElement();
+
+      // match a function.
+      if (commandClass != NULL && objectPointer != NULL && (fktPos == 1 || (fktPos == 2 && inputSplits.getCount() >= 3)))
+      {
+        tIterator<ShellCommandBase>* itCMD = commandClass->commandList->getIterator();
+        ShellCommandBase* enumCMD = itCMD->firstElement();
+        while (enumCMD != NULL)
+        {
+          if (!strcmp(enumCMD->getName(), inputSplits.getString(fktPos)))
+          {
+            if (inputSplits.getCount() > fktPos+1)
+              enumCMD->executeCommand(objectPointer, executionString+inputSplits.getOffset(fktPos +1));
+            else
+              enumCMD->executeCommand(objectPointer, "");
+            delete itCMD;
+            return true;
+          }
+
+          enumCMD = itCMD->nextElement();
+        }
+        delete itCMD;
+
+      }
+
+    }
+
+
+  }
+
 }
 
