Recent

Author Topic: Reading large output with Process  (Read 1749 times)

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Reading large output with Process
« on: September 03, 2015, 04:26:50 pm »
Hi,

I tried to run an external program taht extract image exif info so we have this :
Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var
  s, cmdline: ansistring;
  commands: array of string;
begin
  tik := GetTickCount64;
  cmdline := ExtractFilePath(ParamStr(0)) + 'exiftool.exe';
  SetLength(commands, 2{3});
  commands[0] := '-s';
  commands[1] :=  ExtractFilePath(ParamStr(0)) + 'img1.jpg';
  //commands[2] := '-b';
  if RunCommand(cmdline, commands, s) then
  begin
    Memo1.Append(s);
  end;
end;

And its work very well.
But when I want to get image embedded thumbnail with -b parameter (that work when you run program stand alone or with cmd) and uncomment the two lines,the result code will be :
Code: [Select]
procedure TForm1.Button1Click(Sender: TObject);
var
  s, cmdline: ansistring;
  commands: array of string;
begin
  tik := GetTickCount64;
  cmdline := ExtractFilePath(ParamStr(0)) + 'exiftool.exe';
  SetLength(commands, 3);
  commands[0] := '-s';
  commands[1] :=  ExtractFilePath(ParamStr(0)) + 'img1.jpg';
  commands[2] := '-b';
  if RunCommand(cmdline, commands, s) then
  begin
    Memo1.Append(s);
  end;
end;

now program will get only some of the output although according to wiki it should work:
http://wiki.freepascal.org/Executing_External_Programs#Reading_large_output

where are I go wrong?

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11445
  • FPC developer.
Re: Reading large output with Process
« Reply #1 on: September 03, 2015, 04:42:46 pm »
I don't know. The only known bug (fixed in 3.x) causes a hang, not incomplete output.

Maybe the memo deals badly with #0's in the string? Pipe the command to file, and compare that with length(s), see if those sizes differ.

aradeonas

  • Hero Member
  • *****
  • Posts: 824
Re: Reading large output with Process
« Reply #2 on: September 03, 2015, 05:23:11 pm »
You are right.
I checked it from debugger hint and memo and both have this problem.
Thanks.

 

TinyPortal © 2005-2018