Beispiel #1
0
bool PrintUtility::PrintBranch(GmatCommand* brCmd, Integer level)
{
   GmatCommand* current = brCmd;
   Integer childNo = 0;
   GmatCommand* nextInBranch;
   GmatCommand* child;
   
   while((child = current->GetChildCommand(childNo))!=NULL)
   {
      nextInBranch = child;
      while ((nextInBranch != NULL) && (nextInBranch != current))
      {
         cout << _T("   ");
         for (int i = 0; i <= level ; i++)
            cout << _T("...");
         cout << _T(" branch ") << childNo << _T("::") << nextInBranch->GetTypeName() << endl;
         if (nextInBranch->GetChildCommand() != NULL)
         {
            PrintBranch(nextInBranch, level+1);
         }
         nextInBranch = nextInBranch->GetNext();
      }
      ++childNo;
   }
   
   return true;
}
Beispiel #2
0
//------------------------------------------------------------------------------
const wxString BeginScript::GetChildString(const wxString &prefix,
                                              GmatCommand *cmd,
                                              GmatCommand *parent)
{
   #ifdef DEBUG_BEGINSCRIPT
      MessageInterface::ShowMessage(wxT("BeginScript::GetChildString entered\n"));
   #endif
   
   wxString sstr;
   wxString cmdstr;
   Integer whichOne, start;
   GmatCommand *current = cmd;
   
   while ((current != parent) && (current != NULL))
   {
      cmdstr = current->GetGeneratingString();
      start = 0;
      while (cmdstr[start] == wxT(' '))
         ++start;
      cmdstr = cmdstr.substr(start);
      sstr << prefix << cmdstr << wxT("\n");
      whichOne = 0;
      GmatCommand* child = current->GetChildCommand(whichOne);
      while ((child != NULL) && (child != cmd))
      {
         sstr << GetChildString(prefix + wxT("   "), child, current);
         ++whichOne;
         child = current->GetChildCommand(whichOne);
      }
      current = current->GetNext();
   }
   
   return sstr;
}
Beispiel #3
0
//------------------------------------------------------------------------------
// bool SetBranchCommandChanged(GmatCommand *brCmd, Integer level)
//------------------------------------------------------------------------------
bool GmatCommandUtil::HasBranchCommandChanged(GmatCommand *brCmd, Integer level)
{
   GmatCommand* current = brCmd;
   Integer childNo = 0;
   GmatCommand* nextInBranch = NULL;
   GmatCommand* child;
   std::string cmdstr;
   
   while((child = current->GetChildCommand(childNo)) != NULL)
   {
      nextInBranch = child;
      
      while ((nextInBranch != NULL) && (nextInBranch != current))
      {         
         #ifdef DEBUG_COMMAND_CHANGED
         for (int i=0; i<=level; i++)
            cmdstr = "---" + cmdstr;         
         cmdstr = "--- " + nextInBranch->GetTypeName() + "\n";        
         MessageInterface::ShowMessage("%s", cmdstr.c_str());
         #endif
         
         if (nextInBranch->HasConfigurationChanged())
         {
            #ifdef DEBUG_COMMAND_CHANGED
            MessageInterface::ShowMessage
               ("CommandUtil::HasBranchCommandChanged() returning true\n");
            #endif
            return true;
         }
         
         if (nextInBranch->GetChildCommand() != NULL)
            if (HasBranchCommandChanged(nextInBranch, level+1))
            {
               #ifdef DEBUG_COMMAND_CHANGED
               MessageInterface::ShowMessage
                  ("CommandUtil::HasBranchCommandChanged() returning true\n");
               #endif
               return true;
            }
         nextInBranch = nextInBranch->GetNext();
      }
      
      ++childNo;
   }
   
   #ifdef DEBUG_COMMAND_CHANGED
   MessageInterface::ShowMessage
      ("===> GmatCommandUtil::HasBranchCommandChanged() returning false\n");
   #endif
   return false;
}
Beispiel #4
0
//------------------------------------------------------------------------------
GmatCommand* GmatCommandUtil::GetSubParent(GmatCommand *brCmd, GmatCommand *cmd)
{
   #ifdef DEBUG_GET_PARENT
   ShowCommand
      ("     GmatCommandUtil::GetSubParent() brCmd = ", brCmd, ", cmd = ", cmd);
   #endif
   
   GmatCommand *current = brCmd;
   GmatCommand *child;
   GmatCommand *subParent = NULL;
   Integer childNo = 0;
   
   while((child = current->GetChildCommand(childNo)) != NULL)
   {
      while ((child != NULL) && (child != current))
      {
         if (child == cmd)
         {
            #ifdef DEBUG_GET_PARENT
            ShowCommand
               ("     GmatCommandUtil::GetSubParent() returning ", current);
            #endif
            return current;
         }
         
         if (child->GetChildCommand() != NULL)
            subParent = GetSubParent(child, cmd);
         
         if (subParent != NULL)
            return subParent;
         
         child = child->GetNext();
         
         #ifdef DEBUG_GET_PARENT
         ShowCommand
            ("     GmatCommandUtil::GetSubParent() child = ", child);
         #endif
      }
      
      ++childNo;
   }
   
   #ifdef DEBUG_GET_PARENT
   MessageInterface::ShowMessage
      ("     GmatCommandUtil::GetSubParent() returning NULL\n");
   #endif
   
   return NULL;
}
Beispiel #5
0
//------------------------------------------------------------------------------
bool GmatCommandUtil:: HasCommandSequenceChanged(GmatCommand *cmd)
{
   if (cmd == NULL)
      return false;
   
   GmatCommand *current = cmd;
   std::string cmdstr = cmd->GetTypeName();
   
   #ifdef DEBUG_COMMAND_CHANGED
   MessageInterface::ShowMessage
      ("===> GmatCommandUtil::HasCommandSequenceChanged() entered, "
       "cmd=<%p><%s>\n", cmd, cmdstr.c_str());
   #endif
   
   
   while (current != NULL)
   {
      cmdstr = "--- " + current->GetTypeName() + "\n";
      
      #ifdef DEBUG_COMMAND_CHANGED
      MessageInterface::ShowMessage(cmdstr);
      #endif
      
      if (current->HasConfigurationChanged())
      {
         #ifdef DEBUG_COMMAND_CHANGED
         MessageInterface::ShowMessage
            ("CommandUtil::HasCommandSequenceChanged() returning true\n");
         #endif
         return true;
      }
      
      // go through sub commands
      if ((current->GetChildCommand(0)) != NULL)
      {
         if (HasBranchCommandChanged(current, 0))
         {
            #ifdef DEBUG_COMMAND_CHANGED
            MessageInterface::ShowMessage
               ("CommandUtil::HasCommandSequenceChanged() returning true\n");
            #endif
            
            return true;
         }
      }
      
      current = current->GetNext();
   }
   
   #ifdef DEBUG_COMMAND_CHANGED
   MessageInterface::ShowMessage
      ("===> GmatCommandUtil::HasCommandSequenceChanged() returning false\n");
   #endif
   return false;
}
Beispiel #6
0
//------------------------------------------------------------------------------
GmatCommand* GmatCommandUtil::GetPreviousCommand(GmatCommand *from,
                                                 GmatCommand *cmd)
{
   GmatCommand *current = from;
   GmatCommand *prevCmd = NULL;
   GmatCommand *child = NULL;
   Integer branch = 0;
   
   while (current != NULL)
   {
      if (current == cmd)
         return prevCmd;
      
      // check branch commands
      while ((current->GetChildCommand(branch)) != NULL)
      {
         child = current->GetChildCommand(branch);
         
         while (child != NULL)
         {
            #ifdef DEBUG_PREV_COMMAND
            ShowCommand("   child = ", child);
            #endif
            
            if (child == cmd)
               return prevCmd;
            
            prevCmd = child;
            child = child->GetNext();
         }
         
         branch++;
      }
      
      prevCmd = current;
      current = current->GetNext();
      
   }
   
   return NULL;
}
Beispiel #7
0
//------------------------------------------------------------------------------
bool GmatCommandUtil::IsElseFoundInIf(GmatCommand *ifCmd)
{
   if (ifCmd == NULL)
      return false;
   
   #ifdef DEBUG_IF_ELSE
   ShowCommand
      ("===> GmatCommandUtil::IsElseFoundInIf() ifCmd = ", ifCmd);
   #endif
   
   if (!ifCmd->IsOfType("If"))
   {
      #ifdef DEBUG_IF_ELSE
      MessageInterface::ShowMessage
         ("IsElseFoundInIf() returning false, it is not If command\n");
      #endif
      return false;
   }
   
   GmatCommand *current = ifCmd;
   GmatCommand *child = NULL;
   Integer branch = 0;
   
   // Check only one level first branch
   child = current->GetChildCommand(branch);
   
   while (child != NULL)
   {
      #ifdef DEBUG_IF_ELSE
      ShowCommand("   child = ", child);
      #endif
      
      if (child->IsOfType("BranchEnd"))
      {
         if (child->GetTypeName() == "Else")
         {
            #ifdef DEBUG_IF_ELSE
            MessageInterface::ShowMessage("IsElseFoundInIf() returning true\n");
            #endif
            return true;
         }            
         break;
      }
      
      child = child->GetNext();
   }
   
   #ifdef DEBUG_IF_ELSE
   MessageInterface::ShowMessage("IsElseFoundInIf() returning false\n");
   #endif
   
   return false;
}
Beispiel #8
0
bool PrintUtility::PrintEntireSequence(GmatCommand* firstCmd)
{
   cout << _T(".................... Print out the whole sequence ........................................") << endl;
   GmatCommand *current = firstCmd;
   while (current != NULL)
   {
      cout << _T("   Command::") << current->GetTypeName() << endl;
      if ((current->GetChildCommand(0))!=NULL)
         PrintBranch(current, 0);
      current = current->GetNext();
   }
   cout << _T(".................... End sequence ........................................................") << endl;
   return true;
}
Beispiel #9
0
//------------------------------------------------------------------------------
// void ResetBranchCommandChanged(GmatCommand *brCmd, Integer level)
//------------------------------------------------------------------------------
void GmatCommandUtil::ResetBranchCommandChanged(GmatCommand *brCmd, Integer level)
{
   GmatCommand* current = brCmd;
   Integer childNo = 0;
   GmatCommand* nextInBranch = NULL;
   GmatCommand* child;
   std::string cmdstr;
   
   while((child = current->GetChildCommand(childNo)) != NULL)
   {
      nextInBranch = child;
      
      while ((nextInBranch != NULL) && (nextInBranch != current))
      {         
         #ifdef DEBUG_COMMAND_CHANGED
         for (int i=0; i<=level; i++)
            cmdstr = "---" + cmdstr;         
         cmdstr = "--- " + nextInBranch->GetTypeName() + "\n";        
         MessageInterface::ShowMessage("%s", cmdstr.c_str());
         #endif
         
         nextInBranch->ConfigurationChanged(false);
         
         if (nextInBranch->GetChildCommand() != NULL)
            ResetBranchCommandChanged(nextInBranch, level+1);
         
         nextInBranch = nextInBranch->GetNext();
      }
      
      ++childNo;
   }
   
   #ifdef DEBUG_COMMAND_CHANGED
   MessageInterface::ShowMessage
      ("===> GmatCommandUtil::ResetBranchCommandChanged() leaving\n");
   #endif
}
Beispiel #10
0
//------------------------------------------------------------------------------
GmatCommand* GmatCommandUtil::GetParentCommand(GmatCommand *top, GmatCommand *cmd)
{
   #ifdef DEBUG_GET_PARENT
   ShowCommand
      ("===> GmatCommandUtil::GetParentCommand() top = ", top, ", cmd = ", cmd);
   #endif
   
   GmatCommand *current = top;
   GmatCommand *parent = NULL;
   
   while (current != NULL)
   {
      #ifdef DEBUG_GET_PARENT
      ShowCommand("     current = ", current);
      #endif
      
      if (current == cmd)
      {
         parent = top;
         break;
      }
      
      if ((current->GetChildCommand(0)) != NULL)
      {
         parent = GetSubParent(current, cmd);
         
         #ifdef DEBUG_GET_PARENT
         ShowCommand("     parent = ", current);
         #endif
         
         if (parent != NULL)
            break;
      }
      
      current = current->GetNext();
   }
   
   #ifdef DEBUG_GET_PARENT
   ShowCommand("===> GmatCommandUtil::GetParentCommand() returning ", parent);
   #endif
   
   return parent;
}
Beispiel #11
0
//------------------------------------------------------------------------------
// void ResetCommandSequenceChanged(GmatCommand *cmd)
//------------------------------------------------------------------------------
void GmatCommandUtil::ResetCommandSequenceChanged(GmatCommand *cmd)
{
   if (cmd == NULL)
      return;
   
   GmatCommand *current = cmd;
   std::string cmdstr = cmd->GetTypeName();
   
   #ifdef DEBUG_COMMAND_CHANGED
   MessageInterface::ShowMessage
      ("===> GmatCommandUtil::ResetCommandSequenceChanged() entered, "
       "cmd=<%p><%s>\n", cmd, cmdstr.c_str());
   #endif
   
   while (current != NULL)
   {
      cmdstr = "--- " + current->GetTypeName() + "\n";
      
      #ifdef DEBUG_COMMAND_CHANGED
      MessageInterface::ShowMessage(cmdstr);
      #endif
      
      current->ConfigurationChanged(false);
      
      // go through sub commands
      if ((current->GetChildCommand(0)) != NULL)
         ResetBranchCommandChanged(current, 0);
      
      current = current->GetNext();
   }
   
   #ifdef DEBUG_COMMAND_CHANGED
   MessageInterface::ShowMessage
      ("===> GmatCommandUtil::ResetCommandSequenceChanged() leaving\n");
   #endif
}
Beispiel #12
0
//------------------------------------------------------------------------------
bool GmatCommandUtil::FindObject(GmatCommand *cmd, Gmat::ObjectType objType,
                                 const std::string &objName, std::string &cmdName,
                                 GmatCommand **cmdUsing, bool checkWrappers)
{
   if (cmd == NULL)
      return false;
   
   GmatCommand *current = cmd;
   std::string cmdstr = cmd->GetTypeName();
   
   #ifdef DEBUG_COMMAND_FIND_OBJECT
   MessageInterface::ShowMessage
      ("===> GmatCommandUtil::FindObject() entered, objType=%d, objName='%s', "
       "cmd=<%p><%s>\n", objType, objName.c_str(), cmd, cmdstr.c_str());
   #endif
   
   
   while (current != NULL)
   {
      cmdstr = "--- " + current->GetTypeName() + "\n";
      
      #ifdef DEBUG_COMMAND_FIND_OBJECT
      MessageInterface::ShowMessage(cmdstr);
      #endif
      
      try
      {
         StringArray names = current->GetRefObjectNameArray(objType);
         
         for (UnsignedInt i=0; i<names.size(); i++)
         {
            #ifdef DEBUG_COMMAND_FIND_OBJECT
            MessageInterface::ShowMessage("names[%d]=%s\n", i, names[i].c_str());
            #endif
            
            if (names[i] == objName)
            {
               cmdName = current->GetTypeName();
               *cmdUsing = current;
               #ifdef DEBUG_COMMAND_FIND_OBJECT
               MessageInterface::ShowMessage
                  ("CommandUtil::FindObject() returning true, cmdName='%s', "
                   "cmdUsing=<%p>'%s'\n", cmdName.c_str(), *cmdUsing,
                   (*cmdUsing)->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
               #endif
               return true;
            }
         }
      }
      catch (BaseException &e)
      {
         // Use exception to remove Visual C++ warning
         e.GetMessageType();
         #ifdef DEBUG_COMMAND_FIND_OBJECT
         MessageInterface::ShowMessage("*** INTERNAL WARNING *** " + e.GetFullMessage());
         #endif
      }
      
      // go through sub commands
      if ((current->GetChildCommand(0)) != NULL)
      {
         if (FindObjectFromSubCommands(current, 0, objType, objName, cmdName, cmdUsing, checkWrappers))
         {
            #ifdef DEBUG_COMMAND_FIND_OBJECT
            MessageInterface::ShowMessage
               ("CommandUtil::FindObject() returning true, cmdName='%s', "
                "cmdUsing=<%p>'%s'\n", cmdName.c_str(), *cmdUsing,
                (*cmdUsing)->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
            #endif
            
            return true;
         }
      }
      
      // Check for references in the wrappers, if requested
      if (checkWrappers)
      {
         if (current->HasOtherReferenceToObject(objName))
         {
            cmdName = current->GetTypeName();
            *cmdUsing = current;
            #ifdef DEBUG_COMMAND_FIND_OBJECT
            MessageInterface::ShowMessage
               ("CommandUtil::FindObject() returning true (for wrappers), cmdName='%s', "
                "cmdUsing=<%p>'%s'\n", cmdName.c_str(), *cmdUsing,
                (*cmdUsing)->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
            #endif
            return true;
         }
      }

      current = current->GetNext();
   }
   
   #ifdef DEBUG_COMMAND_FIND_OBJECT
   MessageInterface::ShowMessage
      ("===> GmatCommandUtil::FindObject() returning false\n");
   #endif
   return false;
}
Beispiel #13
0
//------------------------------------------------------------------------------
GmatCommand* GmatCommandUtil::GetMatchingEnd(GmatCommand *cmd, bool getMatchingElse)
{
   if (cmd == NULL)
      return NULL;
   
   #ifdef DEBUG_MATCHING_END
   ShowCommand
      ("===> GmatCommandUtil::GetMatchingEnd() cmd = ", cmd);
   #endif
   
   if (cmd->GetTypeName() != "BeginScript" && !cmd->IsOfType("BranchCommand"))
      return NULL;
   
   GmatCommand *current = cmd;
   
   if (cmd->GetTypeName() == "BeginScript")
   {
      Integer scriptEventCount = 0;
   
      while (current != NULL)
      {
         if (current->GetTypeName() == "BeginScript")
            scriptEventCount++;
      
         if (current->GetTypeName() == "EndScript")
            scriptEventCount--;

         #ifdef DEBUG_MATCHING_END
         MessageInterface::ShowMessage
            ("     scriptEventCount=%d, current=<%p><%s>\n", scriptEventCount, current,
             current->GetTypeName().c_str());
         #endif
      
         if (scriptEventCount == 0)
            break;
      
         current = current->GetNext();
      }
      
      #ifdef DEBUG_MATCHING_END
      ShowCommand("===> GmatCommandUtil::GetMatchingEnd() returning ", current);
      #endif
   
      return current;
   }
   else
   {
      GmatCommand *child = NULL;
      Integer branch = 0;
      bool elseFound = false;
      
      while ((current->GetChildCommand(branch)) != NULL)
      {
         child = current->GetChildCommand(branch);
         
         while (child != NULL)
         {
            #ifdef DEBUG_MATCHING_END
            ShowCommand("   child = ", child);
            #endif
            
            if (child->IsOfType("BranchEnd"))
            {
               if (child->GetTypeName() == "Else")
               {
                  elseFound = true;
                  if (getMatchingElse)
                     break;
                  
                  branch++;
               }
               
               break;
            }
            
            child = child->GetNext();
         }
         
         if (elseFound && branch == 1)
         {
            elseFound = false;
            continue;
         }
         else
            break;
      }
      
      #ifdef DEBUG_MATCHING_END
      ShowCommand("===> GmatCommandUtil::GetMatchingEnd() returning ", child);
      #endif
      
      return child;
   }
}
Beispiel #14
0
//------------------------------------------------------------------------------
// void GetSubCommandString(GmatCommand* brCmd, Integer level, std::string &cmdseq,
//                          bool showAddr = true, bool showGenStr = false,
//                          bool showSummaryName = false,
//                          const std::string &indentStr = "---")
//------------------------------------------------------------------------------
void GmatCommandUtil::
GetSubCommandString(GmatCommand* brCmd, Integer level, std::string &cmdseq,
                    bool showAddr, bool showGenStr, bool showSummaryName,
                    const std::string &indentStr)
{
   char buf[13];
   GmatCommand* current = brCmd;
   Integer childNo = 0;
   GmatCommand* nextInBranch;
   GmatCommand* child;
   std::string cmdstr, genStr;
   buf[0] = '\0';
   
   while((child = current->GetChildCommand(childNo)) != NULL)
   {
      nextInBranch = child;
      
      while ((nextInBranch != NULL) && (nextInBranch != current))
      {
         for (int i=0; i<=level; i++)
         {
            cmdseq.append(indentStr);
            
            #ifdef DEBUG_COMMAND_SEQ_STRING
            MessageInterface::ShowMessage(indentStr);
            #endif
         }
         
         if (showAddr)
            sprintf(buf, "(%p)", nextInBranch);
         
         genStr = "";
			if (showGenStr)
			{
				if (nextInBranch->GetTypeName() == "BeginScript")
					genStr = "<BeginScript>";
				else if (nextInBranch->GetTypeName() == "EndScript")
					genStr = "<EndScript>";
				else
					genStr = " <" + nextInBranch->GetGeneratingString(Gmat::NO_COMMENTS) + ">";
         }
			else if (showSummaryName)
         {
            // Show summary name
            genStr = "(" + nextInBranch->GetSummaryName() + ")";
			}
			
         // if indentation string is not blank, use it from the first sub level
         if (indentStr.find(" ") == indentStr.npos)
            cmdstr = indentStr + " " + std::string(buf) + nextInBranch->GetTypeName() + genStr + "\n";
         else
            cmdstr = std::string(buf) + nextInBranch->GetTypeName() + genStr + "\n";
         
         cmdseq.append(cmdstr);
         
         #ifdef DEBUG_COMMAND_SEQ_STRING
         MessageInterface::ShowMessage("%s", cmdstr.c_str());
         #endif
         
         if (nextInBranch->GetChildCommand() != NULL)
            GetSubCommandString(nextInBranch, level+1, cmdseq, showAddr, showGenStr,
                                showSummaryName, indentStr);
         
         nextInBranch = nextInBranch->GetNext();
      }
      
      ++childNo;
   }
}
Beispiel #15
0
//------------------------------------------------------------------------------
std::string GmatCommandUtil::
GetCommandSeqString(GmatCommand *cmd, bool showAddr, bool showGenStr,
                    bool showSummaryName, const std::string &indentStr)
{
   char buf[13];
   GmatCommand *current = cmd;
   std::string cmdseq, cmdstr, genStr;
   cmdstr = "\n---------- Mission Sequence ----------\n";
   cmdseq.append(cmdstr);
   buf[0] = '\0';
   
   #ifdef DEBUG_COMMAND_SEQ_STRING
   MessageInterface::ShowMessage
      ("===> GmatCommandUtil::GetCommandSeqString(%p)\n", cmd);
   MessageInterface::ShowMessage("%s", cmdstr.c_str());
   #endif
   
   
   while (current != NULL)
   {
      if (showAddr)
         sprintf(buf, "(%p)", current);
      
      genStr = "";
      if (showGenStr)
      {
         if (current->GetTypeName() == "BeginScript")
            genStr = "<BeginScript>";
         else if (current->GetTypeName() == "EndScript")
            genStr = "<EndScript>";
         else
            genStr = " <" + current->GetGeneratingString(Gmat::NO_COMMENTS) + ">";
      }
		else if (showSummaryName)
		{
			// Show summary name
         genStr = "(" + current->GetSummaryName() + ")";
		}
		
      // if indentation string is not blank, use it from the first level
      if (indentStr.find(" ") == indentStr.npos)
         cmdstr = indentStr + " " + std::string(buf) + current->GetTypeName() + genStr + "\n";
      else
         cmdstr = std::string(buf) + current->GetTypeName() + genStr + "\n";
      
      cmdseq.append(cmdstr);
      
      #ifdef DEBUG_COMMAND_SEQ_STRING
      MessageInterface::ShowMessage("%s", cmdstr.c_str());
      #endif
      
      if ((current->GetChildCommand(0)) != NULL)
         GetSubCommandString(current, 0, cmdseq, showAddr, showGenStr, showSummaryName, indentStr);
      
      current = current->GetNext();
   }
   
   cmdseq.append("\n");
   
   return cmdseq;
}
Beispiel #16
0
//------------------------------------------------------------------------------
bool GmatCommandUtil::FindObjectFromSubCommands(GmatCommand *brCmd, Integer level,
                         Gmat::ObjectType objType, const std::string &objName,
                         std::string &cmdName, GmatCommand **cmdUsing, bool checkWrappers)
{
   GmatCommand* current = brCmd;
   Integer      childNo = 0;
   GmatCommand* nextInBranch = NULL;
   GmatCommand* child;
   std::string  cmdstr;
   
   while((child = current->GetChildCommand(childNo)) != NULL)
   {
      nextInBranch = child;
      
      while ((nextInBranch != NULL) && (nextInBranch != current))
      {         
         #ifdef DEBUG_COMMAND_FIND_OBJECT
         for (int i=0; i<=level; i++)
            cmdstr = "---" + cmdstr;         
         cmdstr = "--- " + nextInBranch->GetTypeName() + "\n";        
         MessageInterface::ShowMessage("%s", cmdstr.c_str());
         #endif
         
         try
         {
            StringArray names = nextInBranch->GetRefObjectNameArray(objType);
            
            for (UnsignedInt i=0; i<names.size(); i++)
            {
               #ifdef DEBUG_COMMAND_FIND_OBJECT
               MessageInterface::ShowMessage("names[%d]=%s\n", i, names[i].c_str());
               #endif
               
               if (names[i] == objName)
               {
                  cmdName   = nextInBranch->GetTypeName();
                  *cmdUsing = nextInBranch;
                  #ifdef DEBUG_COMMAND_FIND_OBJECT
                  MessageInterface::ShowMessage
                     ("CommandUtil::FindObjectFromSubCommands() returning true, "
                      "cmdName='%s', cmdUsing=<%p>'%s'\n", cmdName.c_str(), *cmdUsing,
                      (*cmdUsing)->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
                  #endif
                  return true;
               }
            }
         }
         catch (BaseException &e)
         {
            // Use exception to remove Visual C++ warning
            e.GetMessageType();
            #ifdef DEBUG_COMMAND_FIND_OBJECT
            MessageInterface::ShowMessage("*** INTERNAL WARNING *** " + e.GetFullMessage());
            #endif
         }
         
         if (nextInBranch->GetChildCommand() != NULL)
            if (FindObjectFromSubCommands(nextInBranch, level+1, objType, objName, cmdName,
                                          cmdUsing, checkWrappers))
            {
               #ifdef DEBUG_COMMAND_FIND_OBJECT
               MessageInterface::ShowMessage
                  ("CommandUtil::FindObjectFromSubCommands() returning true, "
                   "cmdName='%s', cmdUsing=<%p>'%s'\n", cmdName.c_str(), cmdUsing,
                   (*cmdUsing)->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
               #endif
               return true;
            }

         // Check for references in the wrappers, if requested
         if (checkWrappers)
         {
            if (nextInBranch->HasOtherReferenceToObject(objName))
            {
               cmdName   = nextInBranch->GetTypeName();
               *cmdUsing = nextInBranch;
               #ifdef DEBUG_COMMAND_FIND_OBJECT
               MessageInterface::ShowMessage
                  ("CommandUtil::FindObjectFromSubCommands() returning true (for wrappers), cmdName='%s', "
                   "cmdUsing=<%p>'%s'\n", cmdName.c_str(), *cmdUsing,
                   (*cmdUsing)->GetGeneratingString(Gmat::NO_COMMENTS).c_str());
               #endif
               return true;
            }
         }
         nextInBranch = nextInBranch->GetNext();
      }
      
      ++childNo;
   }
   
   #ifdef DEBUG_COMMAND_FIND_OBJECT
   MessageInterface::ShowMessage
      ("===> GmatCommandUtil::FindObjectFromSubCommands() returning false\n");
   #endif
   return false;
}