[fpc-pascal] Writeln() behaves differently on Windows and Linux, why?

Bo Berglund bo.berglund at gmail.com
Thu Jul 9 18:01:42 CEST 2020


I am writing a cross-platform program (console program, no GUI).
I am using Lazarus 2.0.8 and FPC 3.0.4 on both Linux and Windows.

During sebugging I have put numerous writeln commands in the code to
track what is happening.
I started on Windows and all worked just fine according to
expectations.
Every new output generated a new line on the console with the printed
text left aligned.

But then I moved the code over to Linux (Raspbian Buster) and
strangely this happens:

Test line 1
           Test line 2
                      Test line 3

and so on.
It looks exactly the same if I use a terminal window on the Linux
system itself as it does if I connect to the Linux machine using PuTTY
from Windows...


It seems like a writeln() in the code does actually not do a carriage
return on the console, just a linefeed so the console continues at the
column where the previous line ended.
The messages I print out are simple text strings either showing
incoming data packets or just my comment.

Typical code:

  s := 'Status changed: ' + newstat + ' msg: ' + AStatusText;
  LogStd(s);
  Writeln(s);

In the log file this obviously does not happen...

What can cause this strange behaviour?


-- 
Bo Berglund
Developer in Sweden



More information about the fpc-pascal mailing list