Пример #1
0
 public bool compile(ConsoleBox log)
 {
     try
     {
         Process p = SystemCommand.init(SystemCommand.fpc(), this.getFilename(false));
         p.Start();
         p.WaitForExit();
         string output = p.StandardOutput.ReadToEnd();
         string error  = p.StandardError.ReadToEnd();
         if (p.ExitCode == 0)
         {
             return(true);
         }
         else
         {
             log.textField.Text = StringGenerator.beautify(error + output, this.getFilename(false));
             return(false);
         }
     }
     catch (Exception)
     {
         MessageBox.Show(MainForm.activeForm, "FPC could not be found on your computer! Please visit our homepage for the resolution", "Compile error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return(false);
     }
 }
Пример #2
0
 public void go()
 {
     if (executeThread != null && executeThread.IsAlive)
     {
         stop();
     }
     fileManager.currentFile.synchronize();
     if (fileManager.currentFile.compile(outputBox))
     {
         toRunMode();
         if (isInternalMode)
         {
             executeProcess = SystemCommand.init(CodeFileManager.virtualFilePrefix + StringGenerator.getBaseName(fileManager.currentFile.getFilename(false)) + ".exe", "");
             executeProcess.Start();
             executeThread = new Thread(new ThreadStart(() =>
             {
                 executeProcess.StandardInput.WriteAsync(inputBox.textField.Text + "\n");
                 executeProcess.WaitForExit();
                 string output = executeProcess.StandardOutput.ReadToEnd();
                 string error  = executeProcess.StandardError.ReadToEnd();
                 string time   = "\nProgram executed in " + executeProcess.TotalProcessorTime.TotalSeconds + "s";
                 this.Invoke(new SafeSetText((string text, TextBox textbox) =>
                 {
                     textbox.Text = text;
                     toEditorMode();
                 }), error + output + time, outputBox.textField);
             }));
             executeThread.IsBackground = true;
             executeThread.Start();
         }
         else
         {
             SystemCommand.go(CodeFileManager.virtualFilePrefix + StringGenerator.getBaseName(fileManager.currentFile.getFilename(false)) + ".exe", "");
             toEditorMode();
         }
     }
     else
     {
         toBugMode();
         showDebugBox();
     }
 }