Problem with Tprocess lazarus / 31-LCL ---------------------------------------------------------------------- liewald · 2015-02-09 13:20 Lazarus 1.2.6 r46540 FPC 2.6.4 x86_64-linux-gtk 2 I'm wanting to check the memory usage status in a program I'm running. the easiest way was to call "free -m" using a process.runcommand call, however it appears that Runcommand isn't available in FPC 2.6.4 getmemcall := 'free -g'; process.RunCommand(getmemcall,getmemresult);    yealds main.pas(85,9) Error: identifier idents no member "RunCommand" on compile/build Any Ideas guys Dave ---------------------------------------------------------------------- balazsszekely · 2015-02-09 13:49 Hi liewald, Try this: Code: [Select]uses Process; function MemStatus: String; var   Buffer: array[0..32000] of char;   ReadCount: Integer;   ReadSize: Integer;   Process: TProcess; begin   Result := '';   Process := TProcess.Create(nil);   try     Process.Executable := 'free';   //  Process.Parameters.Add('-g');  //<<--- you can uncoment this line, if you like     Process.Options := [poUsePipes, poStderrToOutPut];     Process.Execute;     while Process.Running do       Sleep(1);     ReadSize := Process.Output.NumBytesAvailable;     ReadSize := SizeOf(Buffer);     if ReadSize > 0 then     begin       ReadCount := Process.Output.Read(Buffer, ReadSize);       if ReadCount > 0 then         Result := Copy(Buffer,0, ReadCount);     end   finally     Process.Free;   end; end; procedure TForm1.Button1Click(Sender: TObject); begin    ShowMessage(MemStatus); end;  regards, GetMem ---------------------------------------------------------------------- liewald · 2015-02-09 13:56 Yup thats what I did to solve it. but there still is the issue of either an error in fpc or the support documentation ---------------------------------------------------------------------- marcov · 2015-02-09 14:06 Quote from: liewald on February 09, 2015, 02:20:31 pmI'm wanting to check the memory usage status in a program I'm running. the easiest way was to call "free -m" using a process.runcommand call, however it appears that Runcommand isn't available in FPC 2.6.4 getmemcall := 'free -g'; process.RunCommand(getmemcall,getmemresult);    yealds Probably you import or define another different "process" symbol somewhere. The following compiles fine already with 2.6.2 Code: [Select]uses process; var getmemcall,getmemresult : ansistring; begin getmemcall := 'free -g'; process.RunCommand(getmemcall,getmemresult);    end. Note that the code posted by getmem is not good for large output. ---------------------------------------------------------------------- liewald · 2015-02-09 14:11 yup it compiled with 2.6.2 seems to be 2.6.4 thats the problem ---------------------------------------------------------------------- marcov · 2015-02-09 14:32 Remover "process." and see if that fixes it. ---------------------------------------------------------------------- liewald · 2015-02-09 14:35 will try ASAP but program running at the moment and takes about 8 hours ---------------------------------------------------------------------- balazsszekely · 2015-02-09 16:51 @marcov QuoteNote that the code posted by getmem is not good for large output. For the command "free -m" is more then enough.  @liewald Function RunCommand is declared in the process unit, but not in the TProcess class, so remove the "process." . The function is deprecated though! ---------------------------------------------------------------------- marcov · 2015-02-09 17:09 Quote from: GetMem on February 09, 2015, 05:51:53 pm@liewald Function RunCommand is declared in the process unit, but not in the TProcess class, so remove the "process." . The function is deprecated though! No it is not. The "program and arguments in one string" version is deprecated because it passes 1:1 to the deprecated "commandline" property of TProcess. The normal versions (with array of string for arguments) are supported. ---------------------------------------------------------------------- balazsszekely · 2015-02-09 17:26 @marcov QuoteNo it is notYes it is.    Take a look at his original post. He's trying to call the deprecated version(the one with two parameters): Code: [Select]process.RunCommand(getmemcall, getmemresult);  PS: Don't take it seriously, I'm just kidding! ---------------------------------------------------------------------- liewald · 2015-02-10 10:48 @marcov QuoteFor the command "free -m" is more then enough.  NAH this is BIG data (260Gb in RAM) will redo using function RunCommand(const exename:string;const commands:array of string;var outputstring:string):boolean;      Thanks Guy's