I am currently writing a small editor for an interpreted programming language. When the program starts, the editor (written in C #) creates a new process that launches the interpreter (written in C ++). The console looks as if it were with any other C ++ program that displays the output of the program.
When an interpreter (i.e. a C ++ program) encounters an error in the code, the message is printed with a standard error, indicating the type of error and the line number on which it occurred. What I would like to do is read the standard interpreter error from the editor, so the editor can highlight the error line as indicated in the error message.
Unfortunately, the code below (designed to read only the standard error) leads to the fact that the standard output of the program also does not print on the console!
private void indicateErrorTest(object sendingProcess, DataReceivedEventArgs outLine)
{
MessageBox.Show(outLine.Data);
}
private void run()
{
program = new Process();
program.StartInfo.FileName = INTERPRETER_PATH;
program.StartInfo.Arguments = "\"" + relativeFilename + "\"";
program.StartInfo.RedirectStandardError = true;
program.StartInfo.UseShellExecute = false;
program.ErrorDataReceived += new DataReceivedEventHandler(indicateErrorTest);
program.Start();
program.BeginErrorReadLine();
program.EnableRaisingEvents = true;
program.Exited += new System.EventHandler(onProgramConsoleClose);
}
I'm not even sure what causes the output to not be written. Otherwise, the program behaves as expected. Is there any way to make standard output still write to the console, while maintaining a standard error? Or is there a better way to get error messages from the interpreter process? Thank.
source
share