Recent

Author Topic: Velthuis.Console.pas - Won't compile in Lazarus  (Read 4584 times)

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #15 on: May 26, 2024, 10:27:48 pm »
Still the same error. I'm on win7 x64.
https://i.postimg.cc/0NrQqqCj/Capture.png
To make velthuisconsole2.zip from Thaddy compile, here a tutorial:
1. download velthuisconsole2.zip
2. extract it in its own project folder
3. rename ConsoleDemo.dpr to ConsoleDemo.lpr
4. open lazarus "Project -> Close Project" if anything is opened
5. select "Open Project"
6. change filemask filter from "Lazarus Project (*.lpi)"  to "All Files (*.*)"
7. locate and doubleclick ConsoleDemo.lpr
8. select "Create Project" -> "Simple Program"
9. press F9 so the file "Velthuis.Console" gets opened
10. scroll to start of file "Velthuis.Console" and...
replace this
Code: Pascal  [Select][+][-]
  1. {$IF DEFINED(FPC)}
  2.   {$DEFINE CompilerVersion=17.0}
  3.   {$MODE DELPHI}
  4.   {$DEFINE HASERROUTPUT}
  5. {$ENDIF}
  6.  
with that
Code: Pascal  [Select][+][-]
  1. {$IF DEFINED(FPC)}
  2.   {$DEFINE CompilerVersion=17.0}
  3.   {$MODE DELPHI}
  4.   {$DEFINE HASERROUTPUT}
  5.   {$ASMMODE intel}
  6. {$ENDIF}
  7.  
and save project.

Does it compile and run?
I just quick tested as 64bit windows target with Lazarus 3.99 (rev main_3_99-2053-g3635aa3044) FPC 3.2.2 x86_64-win64-win32/win64

And please in future copy the error message and paste it in here instead of taking a screenshot and upload it not here.
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Thaddy

  • Hero Member
  • *****
  • Posts: 16763
  • Ceterum censeo Trump esse delendam
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #16 on: May 27, 2024, 09:01:29 am »
@KodeZwerg
In mode delphi asmmode is already intel, because basm is intel. No need.
Indeed you can rename dpr to lpr, but I use Geany so I don't need that.
It does only contain 16 assembly for a hardware sound. I would simply remove that part of the code. I just left it in, but I think Rudy would not have mind if it is removed.
[edit] I found an older working version in which I had actually removed the 16 bit assembler.
Apart from that, the code was the same, though.
« Last Edit: May 27, 2024, 09:12:45 am by Thaddy »
Changing servers. thaddy.com may be temporary unreachable but restored when the domain name transfer is done.

KodeZwerg

  • Hero Member
  • *****
  • Posts: 2269
  • Fifty shades of code.
    • Delphi & FreePascal
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #17 on: May 27, 2024, 10:01:29 am »
@KodeZwerg
In mode delphi asmmode is already intel, because basm is intel. No need.
If you say so but why does it not compile saying the register variables are undeclared and with "{$ASMMODE intel}" they are defined so I can compile, a bug found?
« Last Edit: Tomorrow at 31:76:97 xm by KodeZwerg »

Thaddy

  • Hero Member
  • *****
  • Posts: 16763
  • Ceterum censeo Trump esse delendam
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #18 on: May 27, 2024, 10:18:10 am »
For {$mode delphi} the asm mode should be intel, because of the basm syntax being Intel style. intel. If it isn't it, is a bug.
« Last Edit: May 27, 2024, 10:20:52 am by Thaddy »
Changing servers. thaddy.com may be temporary unreachable but restored when the domain name transfer is done.

Atak_Snajpera

  • New Member
  • *
  • Posts: 31
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #19 on: May 28, 2024, 11:56:08 am »
Still the same error. I'm on win7 x64.
https://i.postimg.cc/0NrQqqCj/Capture.png
To make velthuisconsole2.zip from Thaddy compile, here a tutorial:
1. download velthuisconsole2.zip
2. extract it in its own project folder
3. rename ConsoleDemo.dpr to ConsoleDemo.lpr
4. open lazarus "Project -> Close Project" if anything is opened
5. select "Open Project"
6. change filemask filter from "Lazarus Project (*.lpi)"  to "All Files (*.*)"
7. locate and doubleclick ConsoleDemo.lpr
8. select "Create Project" -> "Simple Program"
9. press F9 so the file "Velthuis.Console" gets opened
10. scroll to start of file "Velthuis.Console" and...
replace this
Code: Pascal  [Select][+][-]
  1. {$IF DEFINED(FPC)}
  2.   {$DEFINE CompilerVersion=17.0}
  3.   {$MODE DELPHI}
  4.   {$DEFINE HASERROUTPUT}
  5. {$ENDIF}
  6.  
with that
Code: Pascal  [Select][+][-]
  1. {$IF DEFINED(FPC)}
  2.   {$DEFINE CompilerVersion=17.0}
  3.   {$MODE DELPHI}
  4.   {$DEFINE HASERROUTPUT}
  5.   {$ASMMODE intel}
  6. {$ENDIF}
  7.  
and save project.

Does it compile and run?
I just quick tested as 64bit windows target with Lazarus 3.99 (rev main_3_99-2053-g3635aa3044) FPC 3.2.2 x86_64-win64-win32/win64

And please in future copy the error message and paste it in here instead of taking a screenshot and upload it not here.
Thank you for all your help! Now everything works fine.

Thaddy

  • Hero Member
  • *****
  • Posts: 16763
  • Ceterum censeo Trump esse delendam
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #20 on: May 28, 2024, 04:57:16 pm »
Glad to be of help. It is a nice piece of code from Rudy. Most of his code is still on-line. There are more gems.
Changing servers. thaddy.com may be temporary unreachable but restored when the domain name transfer is done.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12142
  • FPC developer.
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #21 on: May 28, 2024, 05:31:42 pm »
Except that I warned him (and Jedi) already in 2002-2003 to not use delphi versions directly as a condition in sources.  http://www.stack.nl/~marcov/porting.pdf

Thaddy

  • Hero Member
  • *****
  • Posts: 16763
  • Ceterum censeo Trump esse delendam
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #22 on: May 29, 2024, 07:12:18 am »
Well, that's why I spoof the Delphi version to what is usually compatible with fpc. Saves a lot of work.
You may want to revise your porting.pdf, though: although helpful it is out of date at some points.
Has always been helpful, though.
Changing servers. thaddy.com may be temporary unreachable but restored when the domain name transfer is done.

dculp

  • Full Member
  • ***
  • Posts: 147
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #23 on: March 24, 2025, 09:05:39 am »
Corrected version attached. Both of us did not find that in 2008! We also had a Linux version discussed (Kylix), but was never fnished.
Still using 32 bit Windows? Anyway, I kept it still  somewhat Delphi1 compatible.
In honor of the author.
Try this one, I only changed the order of the Winversion test to be exact:

When building ConsoleDemo.lpr (from velthuisconsole2.zip), I get a number of Message hints (attached). Should I be concerned about any of these?

Lazarus 3.8 (rev lazarus_3_8) FPC 3.2.2 i386-win32-win32/win64

Thanks,
Don C.


marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12142
  • FPC developer.
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #24 on: March 24, 2025, 09:37:11 am »
Probably not in low level code. 

Thaddy

  • Hero Member
  • *****
  • Posts: 16763
  • Ceterum censeo Trump esse delendam
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #25 on: March 24, 2025, 10:04:06 am »
No, these are checked by me when I made the FPC version.
Attached a version with hints removed and some slight improvements.
« Last Edit: March 24, 2025, 10:45:37 am by Thaddy »
Changing servers. thaddy.com may be temporary unreachable but restored when the domain name transfer is done.

dculp

  • Full Member
  • ***
  • Posts: 147
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #26 on: March 24, 2025, 08:02:02 pm »
Commenting all demos except DemoReadKey; -
DemoReadKey doesn't properly deal with Alt+key. For example with the "q" key (output in italics) --

q lowercase             ==> Normal: 'q' = Chr(113)'
Shift+q (uppercase) ==> Normal: 'Q' = Chr(81)'                                                               
Ctrl+q                     ==> Normal: 17                                                                            
Alt+q                  ==> Normal: 'q' = Chr(113)' [just same as q lowercase]
« Last Edit: March 24, 2025, 08:04:01 pm by dculp »

Thaddy

  • Hero Member
  • *****
  • Posts: 16763
  • Ceterum censeo Trump esse delendam
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #27 on: March 25, 2025, 08:55:31 am »
In some DOS or terminal-based programs, Alt-Q might generate an extended key code.
The numeric code for such combinations often starts with 224 (or similar prefixes) followed by an additional code.
This behavior varies across systems.
The problem is that to get the keycode, especially with the modifier keys, you can get side effects because some combinations are mapped to the system.


The above is true, but in this case there is a bug somewhere: the right alt is correct
« Last Edit: March 25, 2025, 10:13:38 am by Thaddy »
Changing servers. thaddy.com may be temporary unreachable but restored when the domain name transfer is done.

dculp

  • Full Member
  • ***
  • Posts: 147
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #28 on: April 02, 2025, 12:48:42 pm »
In the CKeys array, how are the values associated with the Ctrl and Alt combinations determined? For example Ctrl+q = $11 and Alt+q=$110.
Is there some reference for these values or perhaps they were just convenient choices?

cdbc

  • Hero Member
  • *****
  • Posts: 2064
    • http://www.cdbc.dk
Re: Velthuis.Console.pas - Won't compile in Lazarus
« Reply #29 on: April 02, 2025, 12:56:51 pm »
Hi
You should take a good look at @Warfley's excellent library LazTermUtils.
It does turn this console business into a breeze, I use it and it's really good!
When you look at the source, you can see the correlation between the ansi-escape codes you mention and keypresses.
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 3.6 up until Jan 2024 from then on it's both above &: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 4.99

 

TinyPortal © 2005-2018