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

Alexander Grotewohl alex at dcclost.com
Thu Jul 9 18:25:50 CEST 2020


perhaps try 'reset' or 'stty sane' in the terminal before running your program?

are you using the crt or video units at all?

it sounds like your terminal has gotten fudged somehow

--
Alexander Grotewohl
https://dcclost.com
________________________________
From: fpc-pascal <fpc-pascal-bounces at lists.freepascal.org> on behalf of Bo Berglund via fpc-pascal <fpc-pascal at lists.freepascal.org>
Sent: Thursday, July 9, 2020 12:01:42 PM
To: fpc-pascal at lists.freepascal.org <fpc-pascal at lists.freepascal.org>
Cc: Bo Berglund <bo.berglund at gmail.com>
Subject: [fpc-pascal] Writeln() behaves differently on Windows and Linux, why?

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

_______________________________________________
fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20200709/ecc9db05/attachment.htm>


More information about the fpc-pascal mailing list