Recent

Author Topic: Concole model programming  (Read 2072 times)

Andrew1020

  • New member
  • *
  • Posts: 9
Concole model programming
« on: June 10, 2025, 10:32:34 am »
let's put it this way.  I have been away from Pascal programming since 1996.

Can you suggest how should I go about with Pascal console programming, without the Lazarus IDE adding in "commands" into the code editor. 

I just want to do some console programming, before I go on to do basic object-oriented programming leading into GUI programming later on.

My intention is to use Free Pascal in Lazarus for a number of experimentation activities.

Moderator notice: email hidden, to avoid harvesting by bots Please use PM to exchange contact info
« Last Edit: June 12, 2025, 09:22:26 am by marcov »

cdbc

  • Hero Member
  • *****
  • Posts: 2874
    • http://www.cdbc.dk
Re: Concole model programming
« Reply #1 on: June 10, 2025, 10:47:57 am »
Hi
In lazarus:

Menu -> project -> new project -> program -> [OK]
Now lazarus has started a blank console program-skeleton for you, without any GUI Chicky-Micky at all.
To view the output when debugging:
Menu -> View -> Debug Windows -> Console in/output
HTH
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

Thaddy

  • Hero Member
  • *****
  • Posts: 19488
  • Glad to be alive.
Re: Concole model programming
« Reply #2 on: June 10, 2025, 01:20:26 pm »
Don't forget to add a readln at the end of your console program....
Lazarus behaves rather silly otherwise. As opposed to e.g. Geany.
You won't be able to see your console output otherwise.
(and I still think after all those years it would be fixed)
Any "programmer" that knows only one programming language is not a programmer

TBMan

  • Sr. Member
  • ****
  • Posts: 355
Re: Concole model programming
« Reply #3 on: June 10, 2025, 03:30:37 pm »
let's put it this way.  I have been away from Pascal programming since 1996.

Can you suggest how should I go about with Pascal console programming, without the Lazarus IDE adding in "commands" into the code editor. 

I just want to do some console programming, before I go on to do basic object-oriented programming leading into GUI programming later on.

My intention is to use Free Pascal in Lazarus for a number of experimentation activities.

Please reply to me at andrewgoh2032@yahoo.com  Thanks.

I did about the same thing as you. I stopped coding around the turn of the century. When I returned a year or two ago I started back with my Borland Compiler running in DOSBOX (I had transferred the compiler from computer to computer for 30 years, "just in case"). DOSBOX was/is a bit wonky and luckily for me I found Lazarus.

If you are going to code your own GUI there is PTCGraph, PTCcrt and PTCMouse. PTCGraph and PTCCrt and almost perfect replacements for Borland/Turbo Pascal's graph and crt units.

Barry

Newest game (clone),
Missile Commander:
https://www.youtube.com/watch?v=tgKz0cxog-k

Zvoni

  • Hero Member
  • *****
  • Posts: 3442
Re: Concole model programming
« Reply #4 on: June 10, 2025, 03:54:18 pm »
.... and remove your EMail-Address from your first post....
One System to rule them all, One Code to find them,
One IDE to bring them all, and to the Framework bind them,
in the Land of Redmond, where the Windows lie
---------------------------------------------------------------------
Code is like a joke: If you have to explain it, it's bad

Andrew1020

  • New member
  • *
  • Posts: 9
Re: Concole model programming
« Reply #5 on: June 11, 2025, 02:54:33 pm »
I followed the steps right down to console input/output.  But Lazarus doesn't show the output of a simple console program.  Any workarounds.  Basically I am tempted to try Delphi 12 CE.

Thaddy

  • Hero Member
  • *****
  • Posts: 19488
  • Glad to be alive.
Re: Concole model programming
« Reply #6 on: June 11, 2025, 03:05:50 pm »
This:
Code: Pascal  [Select][+][-]
  1. {$mode objfpc}
  2. {$apptype console}// <----- if you are on windows only
  3. begin
  4.   writeln('hello, whatever');
  5.   readln; // <----- if you are on windows only
  6. end.
Should always work.
 
Any "programmer" that knows only one programming language is not a programmer

TBMan

  • Sr. Member
  • ****
  • Posts: 355
Re: Concole model programming
« Reply #7 on: June 11, 2025, 05:17:14 pm »
I use the "Simple Program" selection when creating a new program. Here is a video I made which is essentially the same as Thaddy posted, but starts at the empty project screen.

https://youtu.be/urt1RtXvz90
Barry

Newest game (clone),
Missile Commander:
https://www.youtube.com/watch?v=tgKz0cxog-k

mika

  • Full Member
  • ***
  • Posts: 137
Re: Concole model programming
« Reply #8 on: June 11, 2025, 11:58:27 pm »
For console programing there is Fp shipped with fpc. It is way simpler than Lazarus. With knowledge from year 1996, you will be all set and good. In development branch are a lot fixes and updates to fp. For better experience I suggest to try out that version.  If happen that you use Linux then xterm with custom configuration is a must (Shift+Ins, colors, fonts, copy/paste to OS... ).
« Last Edit: June 12, 2025, 12:09:12 am by mika »

Andrew1020

  • New member
  • *
  • Posts: 9
Re: Concole model programming
« Reply #9 on: June 12, 2025, 05:54:43 am »
Can't the console mode from FPC be build into Lazarus, so that simple mode program can be run in Lazarus, as a major upgrade.

Thaddy

  • Hero Member
  • *****
  • Posts: 19488
  • Glad to be alive.
Re: Concole model programming
« Reply #10 on: June 12, 2025, 06:10:05 am »
You can do console programming in the Lazarus IDE. What makes you think otherwise?
Save my example above as hello.lpr and (re-)open it.
The trick is for  windows is {$apptype console} and the readln at the end.
{$apptype console} sets up input, output and erroutput. for the console. (a.k.a. stdin/stdout/stderr)
The readln at the end is to pause the program so the output is actually shown.
« Last Edit: June 12, 2025, 06:41:31 am by Thaddy »
Any "programmer" that knows only one programming language is not a programmer

TBMan

  • Sr. Member
  • ****
  • Posts: 355
Re: Concole model programming
« Reply #11 on: June 12, 2025, 07:33:32 am »
Can't the console mode from FPC be build into Lazarus, so that simple mode program can be run in Lazarus, as a major upgrade.

Try reading my previous post and actually watch the video. People are giving you the answers and you are ignoring them.
Barry

Newest game (clone),
Missile Commander:
https://www.youtube.com/watch?v=tgKz0cxog-k

cdbc

  • Hero Member
  • *****
  • Posts: 2874
    • http://www.cdbc.dk
Re: Concole model programming
« Reply #12 on: June 12, 2025, 08:19:52 am »
Hi
Here's a 'live' screenshot of lazarus doing exactly what you want, from just a minute ago...  8-)
Follow mine, @Thaddy & TbMan's advice and you are good to go...
Regards Benny

eta: Ohh and this was done in Linux -- remember Thaddy's advice!
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE6/QT6 -> FPC Release -> Lazarus Release &  FPC Main -> Lazarus Main

mika

  • Full Member
  • ***
  • Posts: 137
Re: Concole model programming
« Reply #13 on: June 12, 2025, 09:30:53 am »
Try reading my previous post and actually watch the video. People are giving you the answers and you are ignoring them.

That is not experience that average Joe is having. I am on Linux, but it is not that much different from windows experience.
Lets go least resistance path.

1. Download fpcupdeluxe-x86_64-linux.
2. Select FPC version: Stable, Lazarus version: Stable.
3. Install FPC+Lazarus.
4. Run Lazarus (version 3.6 for some reason).
5. Start New Simple project.
6. Enter "Hello world" program.
7. Run.   (Console does not show up, program is running somewhere hidden).
8. Enable: Menu -> View -> Debug Windows -> Console in/output
9. Run (with debug info). Now there is some sort of pseudo console visible with output (good for debugging GUI apps not doing console programing).

To get console like in your provided video, one have to have prior knowledge how to setup Lazarus properly.

Andrew1020

  • New member
  • *
  • Posts: 9
Re: Concole model programming
« Reply #14 on: June 12, 2025, 09:36:21 am »
How should I go about removing my email and lazarus account from the forum.

 

TinyPortal © 2005-2018