[fpc-pascal] Writeln() behaves differently on Windows and Linux, why?
Bo Berglund
bo.berglund at gmail.com
Thu Jul 9 18:42:54 CEST 2020
On Thu, 9 Jul 2020 16:25:50 +0000, Alexander Grotewohl
<alex at dcclost.com> wrote:
>perhaps try 'reset' or 'stty sane' in the terminal before running your program?
reset in PuTTY gives me a new resized empty screen, but works exactly
the same afterwards.
>are you using the crt or video units at all?
Yes, see below.
>
>it sounds like your terminal has gotten fudged somehow
>
I am using crt in the lpr file just for the sake of being able to shut
it down sensibly:
try
RemoteSrv.ClientPort := 23500; //Set port explicitly
Logger.StdLog('Starting remote server on port: ' +
IntToStr(RemoteSrv.ClientPort));
Writeln('Starting remote server on port: ' +
IntToStr(RemoteSrv.ClientPort));
RemoteSrv.StartServer;
Writeln('Server running, hit q to exit!');
repeat
ch := ReadKey; <== NEEDS unit crt to read the keypress
until ch='q'; {q}
Writeln('Shutting down server');
Logger.StdLog('Shutting down server');
RemoteSrv.StopServer;
finally
RemoteSrv.Free;
end;
Writeln('Terminating program');
The messages put out from this code are all left aligned.
>From then on the messages are stacked sideways but on a new line.
So when the server (it is a TCP/IP socket server) gets a client call
this is written in the console by the writeln() executed inside the
handler as I showed in my start message.
I have tried the Linux terminal on Raspbian Buster and from Windows
PuTTY, both show the same strange behaviour.
If I run the program on Windows this does not happen (same code just
compiled on Windows or Linux).
--
Bo Berglund
Developer in Sweden
More information about the fpc-pascal
mailing list