Recent

Author Topic: Incompatibility between CRT unit and recent Windows 10 versions  (Read 2446 times)

Rich Pasco

  • Newbie
  • Posts: 5
    • Richard C. Pasco
Incompatibility between CRT unit and recent Windows 10 versions
« on: October 24, 2019, 08:32:37 am »
There is an incompatibility between the CRT unit in Free Pascal 3.0.4 and recent versions of Windows 10.

Consider this simple program:

uses CRT;
begin
  while true do
    writeln(ord(ReadKey));
end.


It will write out one or two numbers depending on the key pressed.

If the key has an ASCII code, it writes out the ASCII code.
For example, Shift-A writes 65, the ASCII code for a capital A.

Otherwise it writes out a zero and then the scan code of the key.
For example the F1 key writes out 0 and then 59 (the scan code for F1).

Now consider the key combination Ctrl-End.

When running this program under Windows 10 version 1903, Ctrl-End does absolutely nothing.

When running this program under Windows XP, Windows 7, or ever earlier versions of Windows 10, Ctrl-End writes out 0 and then 117, the scan code for Ctrl-End.

It doesn't matter under which OS the program was compiled.  It only matters under which OS it is executed.

Now it's not the case that Ctrl-End is completely dead in Win 10 ver 1903.  Here is a demo of one case where it does work as intended:
Open a command shell (cmd.exe) window.
On the command line, type a long line of text, then position the cursor in the middle of it, and hit Ctrl-End.  The text to the right of the cursor is deleted as intended.

« Last Edit: October 25, 2019, 12:10:42 am by Rich Pasco »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11446
  • FPC developer.
Re: Incompatibility between CRT unit and recent Windows 10 versions
« Reply #1 on: October 24, 2019, 09:15:55 am »
And these two machines have exactly the same locale and keyboard settings? Windows locale and keyboard settings can change behaviour.

Also new versions of Windows seem to push you toward powershell. Make sure you test under cmd.exe
« Last Edit: October 24, 2019, 09:24:28 am by marcov »

Thaddy

  • Hero Member
  • *****
  • Posts: 14364
  • Sensorship about opinions does not belong here.
Re: Incompatibility between CRT unit and recent Windows 10 versions
« Reply #2 on: October 24, 2019, 09:20:40 am »
Windows 10 has a rewritten console interface - from scratch - and Microsoft acknowledged compatibility problems, so they provide a "compatibility mode" which is actually the old console. Use that and you should be fine.
This is not really an issue that should be solved on the FPC side..
« Last Edit: October 24, 2019, 09:50:44 am by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

rvk

  • Hero Member
  • *****
  • Posts: 6162
Re: Incompatibility between CRT unit and recent Windows 10 versions
« Reply #3 on: October 24, 2019, 10:17:44 am »
There is an incompatibility between the CRT unit in Free Pascal 3.0.4 and recent versions of Windows 10.
...
When running this program under Windows 10 version 1903, Ctrl-End does absolutely nothing.
Indeed, the Ctrl-End doesn't react in 3.0.4 under Windows 10 in Readkey/CRT.

But it does in FPC trunk.
So I guess what was wrong is fixed now.

Rich Pasco

  • Newbie
  • Posts: 5
    • Richard C. Pasco
Re: Incompatibility between CRT unit and recent Windows 10 versions
« Reply #4 on: October 24, 2019, 10:49:16 pm »
And these two machines have exactly the same locale and keyboard settings? Windows locale and keyboard settings can change behaviour.

Also new versions of Windows seem to push you toward powershell. Make sure you test under cmd.exe

Yes, they have the same locale and keyboard settings.  Only the OS version is different.
And Yes, I am using cmd.exe (not Powershell).

Rich Pasco

  • Newbie
  • Posts: 5
    • Richard C. Pasco
Re: Incompatibility between CRT unit and recent Windows 10 versions
« Reply #5 on: October 24, 2019, 11:05:21 pm »
Windows 10 has a rewritten console interface - from scratch - and Microsoft acknowledged compatibility problems, so they provide a "compatibility mode" which is actually the old console. Use that and you should be fine.
This is not really an issue that should be solved on the FPC side..

Do you mean the option circled in red in the attached screen shot?  I tried checking and it seems to fix the issue I reported.

 

TinyPortal © 2005-2018