+ //executes valid command
+ 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 = "";
+ int count = 0;
+
+ //go through string until you reach ; or end
+ while (count < commandString.length()) {
+
+ if (commandString[count] == ';') { break; }
+ else { nextcommand += commandString[count]; }
+
+ count++;
+ }
+
+ //if you are not at the end
+ if (count != commandString.length()) { commandString = commandString.substr(count+1, commandString.length()); }
+ else { commandString = ""; }
+
+
+ //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);
+ }
+}
+/***********************************************************************/