public static void Run()
 {
     using (var scriptcontrol = new ScriptControl()) {
         scriptcontrol.Build();
         ScriptDebugger.Debug(scriptcontrol, false);
     }
 }
Beispiel #2
0
 public ScriptRunner(bool debug)
 {
     _scriptcontrol         = new ScriptControl();
     _scriptcontrol.OnError = OnError;
     _scriptresults         = new List <IScriptResult>();
     _debug = debug;
 }
Beispiel #3
0
 public static Cmd Debug(ScriptControl scriptcontrol, bool stepMode = true) {
     if (stepMode){
         Logger.ConsoleOut.WriteLine("Debug mode: type n for the next execution.");
     } else {
         Logger.ConsoleOut.WriteLine("VisualBasic Script Host Console\nPreface with '?' for an evaluation.");
     }
     try {
         scriptcontrol.WScript.OnEcho += Logger.ConsoleOut.WriteLine;
         StringBuilder buffer = new StringBuilder();
         while (true) {
             Logger.ConsoleOut.Write('>');
             buffer.Length = 0;
             while (true) {
                 string line = Logger.ConsoleIn.ReadLine();
                 if (line == null)
                     break;
                 if (line.Equals("n"))
                     return Cmd.Next;
                 if (string.IsNullOrEmpty(line))
                     break;
                 buffer.AppendLine(line);
                 if ((Control.ModifierKeys & Keys.Shift) == 0)
                     break;
                 Logger.ConsoleOut.Write(' ');
             }
             if (buffer.Length != 0) {
                 string command = buffer.ToString().Trim();
                 if (command.StartsWith("?")) {
                     object result;
                     if (scriptcontrol.Eval(command.Substring(1), out result)) {
                         if(result is string){
                             string txt = "\"" + ((string)result).Replace("\"", "\"\"") + "\"";
                             Logger.ConsoleOut.WriteLine(txt);
                         } else {
                             Logger.ConsoleOut.WriteLine(string.Format("{0}", result));
                         }
                     } else {
                         Logger.ConsoleOut.WriteLine(scriptcontrol.Error.Message);
                     }
                 } else {
                     if (!scriptcontrol.Execute(command))
                         Logger.ConsoleOut.WriteLine(scriptcontrol.Error.Message);
                 }
             }
         }
     } finally {
         scriptcontrol.WScript.OnEcho -= Logger.ConsoleOut.WriteLine;
     }
 }
Beispiel #4
0
 public ScriptRunner(bool debug) {
     _scriptcontrol = new ScriptControl();
     _scriptcontrol.OnError = OnError;
     _scriptresults = new List<IScriptResult>();
     _debug = debug;
 }
Beispiel #5
0
 public static void Run() {
     using (var scriptcontrol = new ScriptControl()) {
         scriptcontrol.Build();
         ScriptDebugger.Debug(scriptcontrol, false);
     }
 }
 public static Cmd Debug(ScriptControl scriptcontrol, bool stepMode = true)
 {
     if (stepMode)
     {
         Logger.ConsoleOut.WriteLine("Debug mode: type n for the next execution.");
     }
     else
     {
         Logger.ConsoleOut.WriteLine("VisualBasic Script Host Console\nPreface with '?' for an evaluation.");
     }
     try {
         scriptcontrol.WScript.OnEcho += Logger.ConsoleOut.WriteLine;
         StringBuilder buffer = new StringBuilder();
         while (true)
         {
             Logger.ConsoleOut.Write('>');
             buffer.Length = 0;
             while (true)
             {
                 string line = Logger.ConsoleIn.ReadLine();
                 if (line == null)
                 {
                     break;
                 }
                 if (line.Equals("n"))
                 {
                     return(Cmd.Next);
                 }
                 if (string.IsNullOrEmpty(line))
                 {
                     break;
                 }
                 buffer.AppendLine(line);
                 if ((Control.ModifierKeys & Keys.Shift) == 0)
                 {
                     break;
                 }
                 Logger.ConsoleOut.Write(' ');
             }
             if (buffer.Length != 0)
             {
                 string command = buffer.ToString().Trim();
                 if (command.StartsWith("?"))
                 {
                     object result;
                     if (scriptcontrol.Eval(command.Substring(1), out result))
                     {
                         if (result is string)
                         {
                             string txt = "\"" + ((string)result).Replace("\"", "\"\"") + "\"";
                             Logger.ConsoleOut.WriteLine(txt);
                         }
                         else
                         {
                             Logger.ConsoleOut.WriteLine(string.Format("{0}", result));
                         }
                     }
                     else
                     {
                         Logger.ConsoleOut.WriteLine(scriptcontrol.Error.Message);
                     }
                 }
                 else
                 {
                     if (!scriptcontrol.Execute(command))
                     {
                         Logger.ConsoleOut.WriteLine(scriptcontrol.Error.Message);
                     }
                 }
             }
         }
     } finally {
         scriptcontrol.WScript.OnEcho -= Logger.ConsoleOut.WriteLine;
     }
 }