Recent

Author Topic: write function and writeLn print cryptic characters into the console  (Read 3137 times)

dankmarius

  • Newbie
  • Posts: 2
So when ever I print something to the console the first line (and only the first) starts with some cryptic characters and I don't know how to fix the issue. I am on Ubuntu and installed the latest lazarus-ide version (1.8.4). The issue only surfaces when I use the CRT package, if it isn't included no problems arise. What can I do to solve this problem?

Handoko

  • Hero Member
  • *****
  • Posts: 5122
  • My goal: build my own game engine using Lazarus
Re: write function and writeLn print cryptic characters into the console
« Reply #1 on: August 20, 2018, 08:18:52 pm »
Hello dankmarius,
Welcome to the forum.

The binary created using Lazarus/FPC works perfectly. Just don't run it using Lazarus Terminal Output (Ctrl+Alt+O), you should run it using the Terminal provided by your Ubuntu.

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: write function and writeLn print cryptic characters into the console
« Reply #2 on: August 20, 2018, 10:19:09 pm »
Just curious, what was the correct text in the first line?

Handoko

  • Hero Member
  • *****
  • Posts: 5122
  • My goal: build my own game engine using Lazarus
Re: write function and writeLn print cryptic characters into the console
« Reply #3 on: August 21, 2018, 03:25:44 am »
Below is the code and the console output using Lazarus Terminal Output.

The bug already existed since first time I used Lazarus on Ubuntu. But because I think it wasn't critical and I do not write console program, I just ignore it. The result binaries will show correctly if I run them using the Terminal provided by Ubuntu.

Code: Pascal  [Select][+][-]
  1. program Project1;
  2.  
  3. uses
  4.   Crt;
  5.  
  6. begin
  7.   WriteLn('Hello');
  8.   WriteLn('World.');
  9.   ReadLn;
  10. end.
« Last Edit: August 21, 2018, 03:29:14 am by Handoko »

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: write function and writeLn print cryptic characters into the console
« Reply #4 on: August 21, 2018, 04:53:04 am »
Thank you!

Code: Pascal  [Select][+][-]
  1. //Laz\fpc\3.0.4\source\packages\rtl-console\src\unix\crt.pp
  2. Initialization
  3. ...
  4.    { Get current X,Y if not set already }
  5.      GetXY(CurrX,CurrY);
  6.      if (CurrX=0) then
  7.       begin
  8.         CurrX:=1;
  9.         CurrY:=1;
  10.         ttySendStr(#27'[H');
  11.       end;
  12.    {Reset Attribute (TextAttr=7 at startup)}
  13.       ttySendStr(#27'[m');
  14. ..

Code: Pascal  [Select][+][-]
  1. //Laz\fpc\3.0.4\source\packages\rtl-console\src\unix\crt.pp
  2. procedure GetXY(var x,y:byte);
  3. ...
  4.   s:=#27'[6n';
  5.   fpWrite(0,s[1],length(s));
  6. ..

Edit:
ESC 0 J: clear from cursor to end of the screen.
ESC 1 J: clear from cursor to beginning of the screen.
ESC 2 J: clear entire screen.

Source.
« Last Edit: August 21, 2018, 05:11:47 am by engkin »

dankmarius

  • Newbie
  • Posts: 2
Re: write function and writeLn print cryptic characters into the console
« Reply #5 on: August 21, 2018, 09:09:36 am »
Thank you very much Handoko, this fiexd my issue.

 

TinyPortal © 2005-2018