Board index » delphi » How to get the screen buffer of a console

How to get the screen buffer of a console

Hi there,

We (me and a friend) are actually working on a project that needs to use
the command line compiler of Delphi. The idea is to let users without
any knowledge of a programming environment compile some code (that they
type within our application) and create a DLL. Thus, as we don't want to
make ourself the code check and compilation, we are calling the command
line compiler Dcc32.exe using CreateProcess. Everything works fine if
the code can be compiled.

A problem appears if the code can't be compiled. Thus, we have to get
the screen buffer of the compiler console to know where an error has
occured during the compilation process. This will let us warn the user
within our application. We have tried to use CreatePipe, but
successless.

Does another way exist to get the errors description from the Dcc32
compiler and if no, how can we read the screen buffer ?

Jack

 

Re:How to get the screen buffer of a console


In article <32B55274.6...@span.ch>, Jacques Bersier <Jacques.Bers...@span.ch>
wrote:
[stuff snipped about capturing output from dcc32 compiler]

Quote
>Does another way exist to get the errors description from the Dcc32
>compiler and if no, how can we read the screen buffer ?

How about doing it the old fashioned way and redirecting the output of the
compiler into a file, and then reading the file contents?

dcc32 test.dpr > dcc32.out

Brian

Re:How to get the screen buffer of a console


If you call the command-line compiler you can check the ErrorLevel.

--
Greetings,
ASS-Ware.

           ,,,
          (o o)
 -----oOO--(_)--OOo-----
|       ASS-Ware        |
|    is watching you    |
 -----------------------

Jacques Bersier <Jacques.Bers...@span.ch> wrote in article
<32B55274.6...@span.ch>...

Quote
> Hi there,

> We (me and a friend) are actually working on a project that needs to use
> the command line compiler of Delphi. The idea is to let users without
> any knowledge of a programming environment compile some code (that they
> type within our application) and create a DLL. Thus, as we don't want to
> make ourself the code check and compilation, we are calling the command
> line compiler Dcc32.exe using CreateProcess. Everything works fine if
> the code can be compiled.

> A problem appears if the code can't be compiled. Thus, we have to get
> the screen buffer of the compiler console to know where an error has
> occured during the compilation process. This will let us warn the user
> within our application. We have tried to use CreatePipe, but
> successless.

> Does another way exist to get the errors description from the Dcc32
> compiler and if no, how can we read the screen buffer ?

> Jack

Re:How to get the screen buffer of a console


Quote
Brian Wright wrote:
> How about doing it the old fashioned way and redirecting the output of the
> compiler into a file, and then reading the file contents?

> dcc32 test.dpr > dcc32.out

We have tried that. It works fine if this line is typed within the
Command prompt window, but not when using CreateProcess.

Jack

Re:How to get the screen buffer of a console


Quote
Jacques Bersier <Jacques.Bers...@span.ch> writes:
>Brian Wright wrote:
>> How about doing it the old fashioned way and redirecting the output of the
>> compiler into a file, and then reading the file contents?

>> dcc32 test.dpr > dcc32.out
>We have tried that. It works fine if this line is typed within the
>Command prompt window, but not when using CreateProcess.

In Borland Pascal you can do:
 Exec(GetEnv('COMSPEC'),'/C dcc32 test.dpr > dcc32.out')
or in BP for Windoze something like:
 WinExec(StrCat(GetEnvStr(Buf,'COMSPEC'),' /C ...'),sw_...)

If Delphi doesn't support Exec or WinExec, you should ask in the *Delphi* Newsgroups -
well you should anyway, this is Borland Pascal.

Frank

Other Threads