Recent

Author Topic: TProcess a executable line by line  (Read 4387 times)

pascalbythree

  • Jr. Member
  • **
  • Posts: 85
TProcess a executable line by line
« on: October 09, 2021, 09:27:56 pm »
Anybody got example code to TProcess a executable and then copy eatch apeard line in a string, line by line?, Greetz Wouter

MarkMLl

  • Hero Member
  • *****
  • Posts: 3535
Re: TProcess a executable line by line
« Reply #1 on: October 09, 2021, 09:34:37 pm »
Is this intended as a continuation of your https://forum.lazarus.freepascal.org/index.php/topic,56655.msg421124.html#msg421124 ?

This isn't IRC, and I'd suggest that once you've started a thread it is appropriate to wait for responses (and to answer people who ask for clarification).

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

Edson

  • Hero Member
  • *****
  • Posts: 1223
Re: TProcess a executable line by line
« Reply #2 on: October 09, 2021, 11:28:10 pm »
You can use: https://github.com/t-edson/UnTerminal

Then capture the output line by line using:

Code: Pascal  [Select][+][-]
  1.   proc := TConsoleProc.Create(nil);
  2.   proc.OnLineCompleted:=@procOnLineCompleted;
  3.   proc.Open('cmd /c dir','');
  4.  
  5. ...
  6.  
  7. procedure TForm1.procOnLineCompleted(const lin: string);
  8. begin
  9.   Memo.Lines.Add(lin);
  10. end;
Lazarus 2.0.10 - FPC 3.2.0 - x86_64-win64 on Windows 8

pascalbythree

  • Jr. Member
  • **
  • Posts: 85
Re: TProcess a executable line by line
« Reply #3 on: October 10, 2021, 05:37:53 pm »
This is 100% procent where i am looking for, UnTerminal-1.0

except its seems to be only to work in lazarus GUI

Do you know  a software package similar for the RaspBian LITE version?

Because it only has to be to work in the console, without GUI.


Edson

  • Hero Member
  • *****
  • Posts: 1223
Re: TProcess a executable line by line
« Reply #4 on: October 10, 2021, 06:17:00 pm »
except its seems to be only to work in lazarus GUI

Do you know  a software package similar for the RaspBian LITE version?

Because it only has to be to work in the console, without GUI.

Check the Example3 project in the Github. It's a console application.

If you don't want to include the LCL dependency, remove the references to TPanel or TTimer in the library. In this case you can use the functions: RunInLoop() to control a process.
Lazarus 2.0.10 - FPC 3.2.0 - x86_64-win64 on Windows 8

pascalbythree

  • Jr. Member
  • **
  • Posts: 85
Re: TProcess a executable line by line
« Reply #5 on: October 10, 2021, 09:00:07 pm »
Only seems to work while xwindows is running. Are you sure it is possible if booted to the command line?

Edson

  • Hero Member
  • *****
  • Posts: 1223
Re: TProcess a executable line by line
« Reply #6 on: October 10, 2021, 11:28:25 pm »
I've tested in Linux and Windows. In command line only in Windows. I don't know what process are you trying to control.
Lazarus 2.0.10 - FPC 3.2.0 - x86_64-win64 on Windows 8

pascalbythree

  • Jr. Member
  • **
  • Posts: 85
Re: TProcess a executable line by line
« Reply #7 on: October 11, 2021, 01:50:53 pm »
Just trying to start Avrdude on a Raspberry lite
then line by line in my fpc console application

So if i may repeat a little, not possible without a linux GUI ?

Thanks.
« Last Edit: October 11, 2021, 01:55:06 pm by pascalbythree »

MarkMLl

  • Hero Member
  • *****
  • Posts: 3535
Re: TProcess a executable line by line
« Reply #8 on: October 11, 2021, 02:14:31 pm »
Just trying to start Avrdude on a Raspberry lite
then line by line in my fpc console application

See the thread you started before. I asked you a couple of specific questions, and you didn't bother to answer.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

prof7bit

  • Full Member
  • ***
  • Posts: 144
Re: TProcess a executable line by line
« Reply #9 on: October 11, 2021, 03:55:03 pm »
answered with a code snippet in your other thread

 

TinyPortal © 2005-2018