Recent

Author Topic: Simple Project output - where's da console?  (Read 2249 times)

decuser

  • Newbie
  • Posts: 3
Simple Project output - where's da console?
« on: February 04, 2024, 11:53:21 pm »
I have a simple project:

Code: Pascal  [Select][+][-]
  1. program EatAtJoes;
  2.  
  3. USES Crt;
  4.  
  5. begin
  6.   ClrScr;
  7.   GotoXY(10,5);
  8.   Writeln('Eat at Joe''s!');
  9.   GotoXY(10,7);
  10.   Writeln('Ten Million Flies Can''t ALL be wrong!');
  11.   Readln;
  12. end.
  13.      


I click run and nothing shows up. After a google search, I see stuff about adding Readln to get it to wait for input. Since I already have it, I'm stumped until I locate the View->Debug Windows->Console In/Output. So, I run that and it pops up with a very nice window that shows something called 'Raw Output' It doesn't look that raw... [6n[H[m[H[2J[5;10HEat at Joe's! looks to me like some control characters and my string. I don't mind, but none of the options gets to what I'd like, which is just my strings showing as what I would get with any terminal app.

So, my questions are:

1. Is it possible to get the output to go to a terminal window provided by the OS (I'm on MX-Linux 23-2 "Libretto" and I have konsole, xterm, and gnome-console available?
2. Is it possible to get it to not show the control characters?
3. Are the control characters coming from the USES Crt thing combining with Writeln?

I'm using debian bookworm's main packages - fpc 3.2.2+dfsg-20 and lazarus 2.2.6+dfsg2-2...

Thanks,

Will

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10261
  • Debugger - SynEdit - and more
    • wiki
Re: Simple Project output - where's da console?
« Reply #1 on: February 05, 2024, 12:31:33 am »
At the moment there is no convenient way to output to a terminal....

There may be 2 ways, but I have tested neither, and they are well... workarounds

1) Use the "gdb server" debugger. Then you can open a shell of your choice, and run your app under gdbserver. You must start that by hand, the IDE will not do it for you. gdb server will pause your project, the IDE can connect to it, and you can debug.

2) using the gdb debugger, in the settings for the gdb debugger is a property grid. It has some setting for a "pty" (I don't have my Linux running now, so not sure of the exact details).
If you have a terminal open, and print that terminals pty, then you can enter it here, and your app will connect to it. But if you do input, it will be shared with the shell....


So neither of those 2 is really good.

On Mac the LLDB debugger can open a terminal, not sure if it can on Linux.



EDIT: the internal tty may even exist for fpdebug (not sure, currently on Windows)
« Last Edit: February 05, 2024, 12:56:50 am by Martin_fr »

decuser

  • Newbie
  • Posts: 3
Re: Simple Project output - where's da console?
« Reply #2 on: February 05, 2024, 12:38:28 am »
Well, it's not the end of the world. I'm only using it for simple pascal anyway. I can live with it and when I really want a terminal, I can just open one and run the app there. I appreciate the workarounds. I'll try them out as time and energy permit. I have confirmed that it's the same situation w/3.0.

cdbc

  • Hero Member
  • *****
  • Posts: 1499
    • http://www.cdbc.dk
Re: Simple Project output - where's da console?
« Reply #3 on: February 05, 2024, 12:47:10 am »
Hi
I do it in one of two ways:
1) I have a konsole(or xterminal) window running on another 'desktop' and
    run my app there to test/see final result.
2) In 'View' -> 'Debug Windows' -> 'Console In/Output', there's an ide-window
    that opens and lets you debug / interact with console. Remember to click on
    it to get focus if you have a 'readln' or so...
    You probably get a lot of escape-codes, but it's doable to debug this way...
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

new2thisagain395

  • New Member
  • *
  • Posts: 19
Re: Simple Project output - where's da console?
« Reply #4 on: March 23, 2024, 02:36:30 pm »
Is there some way to configure that window so it's a little more visually appealing and get rid of the escape codes?  As noted it is workable but it's certainly not great.

cdbc

  • Hero Member
  • *****
  • Posts: 1499
    • http://www.cdbc.dk
Re: Simple Project output - where's da console?
« Reply #5 on: March 23, 2024, 02:42:18 pm »
Hi
"uses Crt;" => Escape-codes!!!
Sorry mate, no.
edit:
On the other hand, I don't think that @Warfley's brilliant library:
https://github.com/Warfley/LazTextForms is quite so strung up on escape codes as the crt-unit. It uses a lot of them, sure, but in more appropriate doses, so to speak  :D
It is certainly worth a 'Looksee'  8-)
The Crt-unit switches the console in 'Raw' mode on unit-startup, whereas Warfley's does it on a per function basis...

Regards Benny
« Last Edit: March 23, 2024, 02:53:45 pm by cdbc »
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

new2thisagain395

  • New Member
  • *
  • Posts: 19
Re: Simple Project output - where's da console?
« Reply #6 on: March 23, 2024, 03:28:19 pm »
Understood.  When I run this app on Windows I get a nice clean console window.

I'm wondering if I should instead create this as a simple windowed app with just a scrolling window, to achieve the same effect regardless of OS.

cdbc

  • Hero Member
  • *****
  • Posts: 1499
    • http://www.cdbc.dk
Re: Simple Project output - where's da console?
« Reply #7 on: March 23, 2024, 04:13:58 pm »
Hi
If you just want basic scrolling text, with NO positioning and colors, then just leave the 'Crt' -unit out of your app altogether... No worries  :D
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

new2thisagain395

  • New Member
  • *
  • Posts: 19
Re: Simple Project output - where's da console?
« Reply #8 on: March 24, 2024, 12:21:17 am »
Actually I will be running this on a Raspberry pi so I'll need it to look like a dumb terminal display (the way the console appears on Windows is perfect).

So I'm wondering if there a simple windowed type of Lazarus project that will mimic the windows console (simple ever-scrolling text)?

cdbc

  • Hero Member
  • *****
  • Posts: 1499
    • http://www.cdbc.dk
Re: Simple Project output - where's da console?
« Reply #9 on: March 24, 2024, 12:55:42 am »
Hi
Try this:
Code: Pascal  [Select][+][-]
  1. program EatAtJoes;
  2.  
  3. var
  4.   I: integer;
  5.  
  6. begin
  7.   for I:= 0 to 4 do Writeln;
  8.   Writeln(#9,'Eat at Joe''s!');
  9.   for I:= 0 to 1 do Writeln;
  10.   Writeln(#9,'Ten Million Flies Can''t ALL be wrong!');
  11.   Readln;
  12. end.
it should look like the other, but free from escape-codes  :D
If you don't _really_ need it, stear clear off "Crt" unit...  :P
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

TRon

  • Hero Member
  • *****
  • Posts: 3176
Re: Simple Project output - where's da console?
« Reply #10 on: March 24, 2024, 11:07:43 am »
1. Is it possible to get the output to go to a terminal window provided by the OS (I'm on MX-Linux 23-2 "Libretto" and I have konsole, xterm, and gnome-console available?
Yes. see picture (open project, menu run, then run parameters) but note that it depends on your Linux distro. If you know how to properly invoke your terminal emulator then simply replace with what your distro requires/needs.

Quote
2. Is it possible to get it to not show the control characters?
No idea, I never use unit crt.

Quote
3. Are the control characters coming from the USES Crt thing combining with Writeln?
Probably.
All software is open source (as long as you can read assembler)

decuser

  • Newbie
  • Posts: 3
Re: Simple Project output - where's da console?
« Reply #11 on: March 31, 2024, 05:26:20 pm »
Great answers all. The run parameters change was the best suggestion, as it just worked, but getting rid of CRT was informative and useful information that I will take to heart.

Thaddy

  • Hero Member
  • *****
  • Posts: 15555
  • Censorship about opinions does not belong here.
Re: Simple Project output - where's da console?
« Reply #12 on: March 31, 2024, 07:25:06 pm »
Try this. also better cross platform;
Code: Pascal  [Select][+][-]
  1. program EatAtJoes;
  2. uses ptcCrt;
  3.  
  4. begin
  5.   ClrScr;
  6.   GotoXY(10,5);
  7.   Writeln('Eat at Joe''s!');
  8.   GotoXY(10,7);
  9.   Writeln('Ten Million Flies Can''t ALL be wrong!');
  10.   Readln;
  11. end.
you do not need to install anything, it is also in the standard distribution.
« Last Edit: March 31, 2024, 07:28:01 pm by Thaddy »
If I smell bad code it usually is bad code and that includes my own code.

 

TinyPortal © 2005-2018