On Wed, 09 Dec 2009, Szak�ts Viktor wrote:

Hi,

> > Just to show the other benefits it renders.
> > I am simply short of process API in Harbour,
> > examined hbprocfn.c to go through all the details,
> > but I could not find how to capture process output
> > in buffer which process is in running state. 

   hProcess := HB_PROCESSOPEN( <cCommand>, NIL, @hStdOut, @hStderr, lDeatch )

It creates new process and you can read form hStdOut and hStderr
the process output.
You can check running process state using
   nState := HB_PROCESSVALUE( hProcess, lWait )
Do not forget to close all handles passed by reference to HB_PROCESSOPEN()
using FCLOSE() function when they are not longer necessary.

Please only remember that HB_PROCESSOPEN() does not work for platforms
which do not support simultaneous multiprocessing.
HB_PROCESSRUN() works for all platforms and if necessary standard files
are used to exchange stdin/stdout/stderr data.

> > I can see that stdout and stderr andles but do not
> > know hoe effectively I can use them.
> > Plus hb_processRun() opens the console window 
> > which I do not want to.

It's not true. Neither hb_processRun() nor hb_processOpen() creates
console window. Such window can be created only by executed application
and it's out of calling process control. It doesn't matter how you
will call it. You can only try to pass to executed application request
to minimize such window using lDetach or some parameter like //gtnul
for [x]Harbour applications which disables default GT.

> > I must be missing on this front, that's why
> > I had requested the api syntax.

QT is only upper level wrapper to the same low level CreateProcess()
function.

> > Qt process implementation will take only two minutes
> > to remove from SVN, I was just comparing the results
> > from both impleentations.
> Okay. IMO you should ask above things from Przemek 
> to see how process API can be used for such things 
> like catching stdout/err in real-time.

HB_PROCESSOPEN() then FREAD() until HB_PROCESSVALUE() == -1
and then FCLOSE() for open handles.
If you plan to implement everything in single thread and make
in the loop some other things then probably you will need sth
like wrapper to WAPI WaitForSingleObject() or WaitForMultipleObjects()
to avoid freezing the process on
      FREAD( hStdOut, @cBuff, len( cBuff ) )
That's all.

best regards,
Przemek
_______________________________________________
Harbour mailing list (attachment size limit: 40KB)
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to