+ //executes valid command
+ CommandFactory cFactory;
+ Command* command = cFactory.getCommand(commandName, options);
+ quitCommandCalled = command->execute();
+ }else {
+ mothurOut("Invalid.");
+ mothurOutEndLine();
+ }
+
+ }
+
+ return 1;
+ }
+ catch(exception& e) {
+ errorOut(e, "ScriptEngine", "getInput");
+ exit(1);
+ }
+}
+/***********************************************************************/
+string ScriptEngine::getNextCommand(string& commandString) {
+ try {
+ string nextcommand = "";
+
+ nextcommand = commandString.substr(0,commandString.find_first_of(';'));
+
+
+ if ((commandString.find_first_of(';')+1) <= commandString.length()) {
+ commandString = commandString.substr(commandString.find_first_of(';')+1, commandString.length());
+ }else { commandString = ""; } //you have reached the last command.
+
+ //get rid of spaces in between commands if any
+ if (commandString.length() > 0) {
+ while (commandString[0] == ' ') {
+ commandString = commandString.substr(1,commandString.length());
+ if (commandString.length() == 0) { break; }
+ }
+ }
+
+ return nextcommand;
+ }
+ catch(exception& e) {
+ errorOut(e, "ScriptEngine", "getNextCommand");
+ exit(1);
+ }
+}
+/***********************************************************************/