Re: [Lazarus] Cloning standard output to text file

2018-05-04 Thread Carlos E. R. via Lazarus
On 2018-05-04 19:30, Marco van de Voort via Lazarus wrote:
> On Fri, May 04, 2018 at 01:31:50PM +0200, Carlos E. R. via Lazarus wrote:
>> Now I have to figure out how to write both to file and screen :-)
> 
> fpc streamio
> 

Results in church related links, LOL.


Better "freepascal streamio".



«The StreamIO unit implements a call to reroute the input or output of a
text file to a descendents of TStream.»


Sorry, I fail to see how I can use this with writeln to write to *both*
output and file at the same time. Maybe I miss something :-?

-- 
Cheers / Saludos,

Carlos E. R.
(from 42.3 x86_64 "Malachite" at Telcontar)



signature.asc
Description: OpenPGP digital signature
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Cloning standard output to text file

2018-05-04 Thread Carlos E. R. via Lazarus
On 2018-05-04 18:46, Reimar Grabowski via Lazarus wrote:
> On Fri, 4 May 2018 13:34:54 +0200
> "Carlos E. R. via Lazarus"  wrote:
> 
>> Yes, of course, that's what I'm doing now, but I wanted to do it
>> internally, control the file name, perhaps rotate it, etc :-)
> Perhaps you should use a logger.
> There are surely some FPC ones out there that can do all this for you.
> A fast google search brings up http://wiki.freepascal.org/Log4Delphi which is 
> based on Log4J (which does all that).

Well, I send to syslog the important things :-)

In this phase I use many writeln as debug help, and using a pipe and a
tee does the job fine.

The idea here:
 redirects
all stdout to a file, but I'm thinking that it is basically the same as
replacing all writeln found with writeln(F, ...), achieving the same
thing perhaps simpler. Well, except that commenting out a the call to
"redirect" disables it.

The basic trick it does is:

var
  f : TextFile;
  s: TDebugStream;

and a procedure to redirect the output:


procedure redirect;
begin
 s := TDebugStream.Create();
 AssignStream(f, s);
 Rewrite(f);
 output := f;
end;


wich replaces stdout (output) with f. The role of tTDebugStream I don't
get. It is created thus:



Type
  TDebugStream = class(TStream)
function Write(const Buffer; Count : Longint) : Longint; override;
  end;

implementation

function TDebugStream.Write(const Buffer; Count : Longint) : Longint;
var
  msg : ansistring;

begin
  result := count;
  SetLength(msg, count);
  move(buffer, PChar(msg)[0], count);
  OutputDebugString(PChar(TrimRight(msg)));
end;



I also miss where the file name is assigned.


But anyway, what I wanted is to write both to the screen and to a file,
so this is not sufficient.


Further in the thread they say that this would do - this is the classic
method I had forgotten:


var
   oldoutput, f: TextFile;
begin
   AssignFile(f, 'somefile');
   Rewrite(f);
   oldoutput := Output;
   Output := f;
   Writeln('Hello World'); // this is send to Output
   Output := oldoutput;
   CloseFile(f);
end.

At the start of the thread there is a suggestion to "implementing your
own textfile driver", but the link is dead.



-- 
Cheers / Saludos,

Carlos E. R.
(from 42.3 x86_64 "Malachite" at Telcontar)



signature.asc
Description: OpenPGP digital signature
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Cloning standard output to text file

2018-05-04 Thread Marco van de Voort via Lazarus
On Fri, May 04, 2018 at 01:31:50PM +0200, Carlos E. R. via Lazarus wrote:
> Now I have to figure out how to write both to file and screen :-)

fpc streamio
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Cloning standard output to text file

2018-05-04 Thread Reimar Grabowski via Lazarus
On Fri, 4 May 2018 13:34:54 +0200
"Carlos E. R. via Lazarus"  wrote:

> Yes, of course, that's what I'm doing now, but I wanted to do it
> internally, control the file name, perhaps rotate it, etc :-)
Perhaps you should use a logger.
There are surely some FPC ones out there that can do all this for you.
A fast google search brings up http://wiki.freepascal.org/Log4Delphi which is 
based on Log4J (which does all that).

hih
R.
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Cloning standard output to text file

2018-05-04 Thread Carlos E. R. via Lazarus
On 2018-05-04 13:30, Bart via Lazarus wrote:
> On Fri, May 4, 2018 at 12:51 PM, Carlos E. R. via Lazarus
>  wrote:
> 
>> I want to do a series of "writeln(...)" and have the output go
>> simultaneously to the console and to a text file of my choice. I have
>> the vague idea that this was done writing a text file handler :-?
> 
> I once wrote a simple utility (myutil) that read from stdin, echoed to
> stdout and echoed to a logfile.
> I then used a pipe from the commandline to achieve what I wanted.
> E.g.:
> 
> myprog | mytuil path/to/log
> 
> Or something similar to that.

Yes, of course, that's what I'm doing now, but I wanted to do it
internally, control the file name, perhaps rotate it, etc :-)


Actually:

myprog | tee mytuil path/to/log



It has the effect that text to screen is written in chunks, may stop at
the middle of a line. So at the end each cycle, I issue a "flush(output);"

-- 
Cheers / Saludos,

Carlos E. R.
(from 42.3 x86_64 "Malachite" at Telcontar)



signature.asc
Description: OpenPGP digital signature
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Cloning standard output to text file

2018-05-04 Thread Carlos E. R. via Lazarus
On 2018-05-04 12:58, Mattias Gaertner via Lazarus wrote:
> On Fri, 4 May 2018 12:51:38 +0200
> "Carlos E. R. via Lazarus"  wrote:
> 
>> [...]
>> I want to do a series of "writeln(...)" and have the output go
>> simultaneously to the console and to a text file of my choice. I have
>> the vague idea that this was done writing a text file handler :-?
>> [...]
>> If you know of a google search string to locate these ideas, just tell
>> me ;-)
> 
> fpc redirect stdout

Thank you!  :-)

Found it. At least for redirection, the output is sent to a file.



Now I have to figure out how to write both to file and screen :-)

More ideas to investigate here:



-- 
Cheers / Saludos,

Carlos E. R.
(from 42.3 x86_64 "Malachite" at Telcontar)



signature.asc
Description: OpenPGP digital signature
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Cloning standard output to text file

2018-05-04 Thread Bart via Lazarus
On Fri, May 4, 2018 at 12:51 PM, Carlos E. R. via Lazarus
 wrote:

> I want to do a series of "writeln(...)" and have the output go
> simultaneously to the console and to a text file of my choice. I have
> the vague idea that this was done writing a text file handler :-?

I once wrote a simple utility (myutil) that read from stdin, echoed to
stdout and echoed to a logfile.
I then used a pipe from the commandline to achieve what I wanted.
E.g.:

myprog | mytuil path/to/log

Or something similar to that.

Bart
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Cloning standard output to text file

2018-05-04 Thread Mattias Gaertner via Lazarus
On Fri, 4 May 2018 12:51:38 +0200
"Carlos E. R. via Lazarus"  wrote:

>[...]
> I want to do a series of "writeln(...)" and have the output go
> simultaneously to the console and to a text file of my choice. I have
> the vague idea that this was done writing a text file handler :-?
>[...]
> If you know of a google search string to locate these ideas, just tell
> me ;-)

fpc redirect stdout

Mattias
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


[Lazarus] Cloning standard output to text file

2018-05-04 Thread Carlos E. R. via Lazarus
Hi,

I know I did this decades ago with Turbo Pascal, but I can't remember
how, and my google foo fails me.

I want to do a series of "writeln(...)" and have the output go
simultaneously to the console and to a text file of my choice. I have
the vague idea that this was done writing a text file handler :-?

I can of course do two writeln calls for each current call, but it is a
nuisance.

I can not use a mywriteln wrapper that would do the two calls, because I
do not know how to create a procedure that takes a variant number of
parameters, as "writeln()" does...

Ideas?

If you know of a google search string to locate these ideas, just tell
me ;-)

-- 
Cheers / Saludos,

Carlos E. R.
(from 42.3 x86_64 "Malachite" at Telcontar)



signature.asc
Description: OpenPGP digital signature
-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus


Re: [Lazarus] Dark themed lazarus

2018-05-04 Thread Andreas Frieß via Lazarus
Maciej Izak via Lazarus wrote:

> 2018-04-05 12:16 GMT+02:00 Anthony Walter via Lazarus <
> lazarus@lists.lazarus-ide.org>:
> 
> > Next I might tackle the lagginess in drag moving controls on the
> > form designer. Does that seem like a laggy problem to anyone else?
> > 
> 
> Probably you mean : https://bugs.freepascal.org/view.php?id=33486

This Bugreport have not only to do with moving a component. Switching
between code and design is the strangest lag.

> 
> I was not able to spend enough time on this problem, so any patch is
> welcome.
> 
> -- 
> Best regards,
> Maciej Izak

Andreas

-- 
___
Lazarus mailing list
Lazarus@lists.lazarus-ide.org
https://lists.lazarus-ide.org/listinfo/lazarus