[Lazarus] send complex command to linux
AndrewD207 at aol.com
Wed Dec 22 17:40:08 CET 2010
On 12/22/10 04:58, Lukasz Sokol wrote:
> Very Nice, can I ask, just:
>> while Flac.Running or (Flac.Output.NumBytesAvailable > 0) do
> Can this conditon happen to hit
> ..NumBytesAvailable > 0 (it'll probably be some garbage, but still)
No. Flac.Output is not initialized until Flac.Execute has succeded.
As soon as Flac.Execute is called Flac.Running = true unless an error
I did while loop like that in case Flac stopped running but we hadn't
finished reading all it's data.
> and would it be dangerous if so it happened ?
> Maybe another
> while not Flac.Running do
> Application.ProcessMessages; // or even without this one
> be put at  ?
This *could* cause an inescapable loop if for instance flac exited
before this was reached because we gave it some wrong options.
A safer example would be:
Flac := TProcess.Create(nil);
Flac.Commandline := 'flac <some options>';
Flac.Options = [poUsePipes];
Flac.Execute; // this will raise an exception if it
// cannot find or execute the command
ShowMessage('Error running Flac! Command Not Found');
if not Flac.Running then
// this will happen if flac ran but encountered
if Flax.ExitStatus <> 0 then
ShowMessage('Flac exited with an error: ' +
else // Flac ran and has already finished with some data or is still
While Flac.Running or (Flac.Output.NumBytesAvailable > 0) do
Hope this clears things up :)
PS I didn't compile that so ther may be an error or three :)
More information about the Lazarus