Hello everyone!

I am trying to write a front-end for the command-line archiving program
"dar" ( http://dar.linux.free.fr/ )

I can read happily from the dar Process.Output but am not managing to
respond using Process.Input

When extracting an archive using the commandline, when dar finds a file
to be overwritten, it asks if it should be overwritten, to which the
response is [RETURN] key  for 'Yes' or [ESC] key for  'NO'. I have tried
writing both #13 and #27 to Process.Input but it has no effect: the
program just hangs as the Process never stops running and gives no more
output.

The relevant bit of code is given below. Can anyone suggest what the
problem could be?

Malcolm

Using fpc 2.2.0 and Lazarus 0.9.24 on Linux: Proc.Options :=
[poUsePipes, poStdErrToOutput]

         while i <= Count do
               begin
               if (StdOutBuf[i] in [#10,#13]) or (i = Count) then
                  begin
                  OutputLine := copy(StdOutBuf, LineStart, i-LineStart);
                  if Pos('is about to be over', OutputLine) > 0 then
                       case MessageDlg('Confirm overwrite file',
                             'Overwrite ' + Copy(OutputLine, 1, Pos('is
about to be over', OutputLine)-2),
                             mtConfirmation,
                             [mbYes, mbNo, mbCancel], 0)
                               of
                               mrYes: begin
                                      SetLength(StdInBuf, 1);
                                      StdInBuf[1] := CHR(VK_RETURN);
                                      writeln('Bytes sent
',Proc.Input.Write(StdInBuf[1], Length(StdInBuf)));
                                      end;
                               mrNo: begin
                                      SetLength(StdInBuf, 1);
                                      StdInBuf[1] := CHR(VK_ESCAPE);
                                      writeln('Bytes sent
',Proc.Input.Write(StdInBuf[1], Length(StdInBuf)));
                                      end;
                               mrCancel: Proc.Terminate(0);  // this
option works: Proc terminates and the app continues normally
                               end;
                  if OutputLine <> '' then
                     MessageMemo.Lines.Add(OutputLine);
                  OutputLine := '';
                  if (i<Count) and (StdOutBuf[i+1] in [#10,#13]) and
(StdOutBuf[i]<>StdOutBuf[i+1])
                     then Inc(i);
                  LineStart := i+1;
                  Application.ProcessMessages;
                  end;
               Inc(i);
               end;


_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to