Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2020-04

Windows Console App

7 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ozz Nixon

Anyone ever experience making a console app (cross-platform), but, on windows when the app finishes, it appears to have put an uppercase C or D in the keyboard buffer, so the Prompt now has C:\>D<cursor> ???

Every time I run my app, be it show help screen and end, or actually execute - when it finishes I end up with a letter sitting at the prompt. (A few months ago, I was having a problem, and it was related to compiling all of the methods with cdecl. That build would leave a stray "C" at the start of the prompt upon exiting. Now, I ran into a new problem where I needed to recompile with -FcUTF8 to track down which units it thought were having a UTF-8 mismatch... it was showing the wrong unit until I used the -FcUTF8 compile option, then it actually showed what file had '<highbit ascii>' strings ... so I switched to #<byte_number> and it compiles, but, the prompts have "D" at the start of them now. (hopefully I described that understandable).

Environment: Windows XP 32bit
C:\FPC\3.0.4\bin\i386-Win32\fpc.exe

If no one else has experienced/has a solution, I will sit down and bang out test cases until I find what combination (units, code, whatever) is producing this result.

Ozz

Reply by email

Gerhard Scholz
to Ozz Nixon

Hi,

I would like to know how you did that since it was exactly what I was searchomg for a while ago...

Could you send me a piece of code?

Greetings

Gerhard

Earlier message 40 lines
----- Original Message ----- From: Ozz Nixon via fpc-devel To: FPC developers' list Cc: Ozz Nixon Sent: Sunday, April 26, 2020 2:21 AM Subject: [fpc-devel] Windows Console App Anyone ever experience making a console app (cross-platform), but, on windows when the app finishes, it appears to have put an uppercase C or D in the keyboard buffer, so the Prompt now has C:\>D<cursor> ??? Every time I run my app, be it show help screen and end, or actually execute - when it finishes I end up with a letter sitting at the prompt. (A few months ago, I was having a problem, and it was related to compiling all of the methods with cdecl. That build would leave a stray "C" at the start of the prompt upon exiting. Now, I ran into a new problem where I needed to recompile with -FcUTF8 to track down which units it thought were having a UTF-8 mismatch... it was showing the wrong unit until I used the -FcUTF8 compile option, then it actually showed what file had '<highbit ascii>' strings ... so I switched to #<byte_number> and it compiles, but, the prompts have "D" at the start of them now. (hopefully I described that understandable). Environment: Windows XP 32bit C:\FPC\3.0.4\bin\i386-Win32\fpc.exe If no one else has experienced/has a solution, I will sit down and bang out test cases until I find what combination (units, code, whatever) is producing this result. Ozz

Reply by email

Ozz Nixon
to Gerhard Scholz

Sure! I assume you are asking how to make a console app?

You do not need {$APPTYPE CONSOLE} ... instead, you simply write your code like normal:

Program example;
Uses
   CRT;
Begin
   ClrScr;
   Writeln('Wassup?!');
   Readln;
End.

then in the command prompt (any OS), simply fpc example .... then .\example, or ./example - depending upon your OS... voila. "Console App".... now, that is not a DOS 16bit APP... that requires other mess, and since I own Turbo Pascal 7.0 source, I have my own TP 32bit compiler that produces TP 7 compatible 16bit Units and Apps. ;-)

@ you can get me at if you need any help (I do not normally code GUI apps - money in the Legacy market) so I have made a wide range of solutions. This email was started because of something odd on Windows recently for me...

Ozz

AM Gerhard Scholz wrote 62 lines
Hi, I would like to know how you did that since it was exactly what I was searchomg for a while ago... Could you send me a piece of code? Greetings Gerhard ----- Original Message ----- From: Ozz Nixon via fpc-devel To: FPC developers' list Cc: Ozz Nixon Sent: Sunday, April 26, 2020 2:21 AM Subject: [fpc-devel] Windows Console App Anyone ever experience making a console app (cross-platform), but, on windows when the app finishes, it appears to have put an uppercase C or D in the keyboard buffer, so the Prompt now has C:\>D<cursor> ??? Every time I run my app, be it show help screen and end, or actually execute - when it finishes I end up with a letter sitting at the prompt. (A few months ago, I was having a problem, and it was related to compiling all of the methods with cdecl. That build would leave a stray "C" at the start of the prompt upon exiting. Now, I ran into a new problem where I needed to recompile with -FcUTF8 to track down which units it thought were having a UTF-8 mismatch... it was showing the wrong unit until I used the -FcUTF8 compile option, then it actually showed what file had '<highbit ascii>' strings ... so I switched to #<byte_number> and it compiles, but, the prompts have "D" at the start of them now. (hopefully I described that understandable). Environment: Windows XP 32bit C:\FPC\3.0.4\bin\i386-Win32\fpc.exe If no one else has experienced/has a solution, I will sit down and bang out test cases until I find what combination (units, code, whatever) is producing this result. Ozz _______________________________________________ fpc-devel maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Alexander Grotewohl
to Ozz Nixon: Anyone ever experience making a console app (cross-platform), but, on windows when the…

you're not using the crt unit are you? first because i think it doesn't support utf8 and second because i think you can cause this by doing "if keypressed.." without then doing readkey before exit.

Alexander Grotewohl https://dcclost.com ________________________________
Earlier message 16 lines
From: fpc-devel on behalf of Ozz Nixon via fpc-devel Sent: Saturday, April 25, 2020 8:21:13 PM To: FPC developers' list Cc: Ozz Nixon Subject: [fpc-devel] Windows Console App Anyone ever experience making a console app (cross-platform), but, on windows when the app finishes, it appears to have put an uppercase C or D in the keyboard buffer, so the Prompt now has C:\>D<cursor> ??? Every time I run my app, be it show help screen and end, or actually execute - when it finishes I end up with a letter sitting at the prompt. (A few months ago, I was having a problem, and it was related to compiling all of the methods with cdecl. That build would leave a stray "C" at the start of the prompt upon exiting. Now, I ran into a new problem where I needed to recompile with -FcUTF8 to track down which units it thought were having a UTF-8 mismatch... it was showing the wrong unit until I used the -FcUTF8 compile option, then it actually showed what file had '<highbit ascii>' strings ... so I switched to #<byte_number> and it compiles, but, the prompts have "D" at the start of them now. (hopefully I described that understandable). Environment: Windows XP 32bit C:\FPC\3.0.4\bin\i386-Win32\fpc.exe If no one else has experienced/has a solution, I will sit down and bang out test cases until I find what combination (units, code, whatever) is producing this result. Ozz

Reply by email

Ozz Nixon
to Alexander Grotewohl

I will check your suggestions Alexander.

Checked the code, it does if paramcount=0 then show help, then exit from main begin/end. It does not interact with the keyboard unless instructed to (its a pascal script engine).

AM Alexander Grotewohl wrote 43 lines
you're not using the crt unit are you? first because i think it doesn't support utf8 and second because i think you can cause this by doing "if keypressed.." without then doing readkey before exit. -- Alexander Grotewohl https://dcclost.com ------------------------------ *From:* fpc-devel on behalf of Ozz Nixon via fpc-devel *Sent:* Saturday, April 25, 2020 8:21:13 PM *To:* FPC developers' list *Cc:* Ozz Nixon *Subject:* [fpc-devel] Windows Console App Anyone ever experience making a console app (cross-platform), but, on windows when the app finishes, it appears to have put an uppercase C or D in the keyboard buffer, so the Prompt now has C:\>D<cursor> ??? Every time I run my app, be it show help screen and end, or actually execute - when it finishes I end up with a letter sitting at the prompt. (A few months ago, I was having a problem, and it was related to compiling all of the methods with cdecl. That build would leave a stray "C" at the start of the prompt upon exiting. Now, I ran into a new problem where I needed to recompile with -FcUTF8 to track down which units it thought were having a UTF-8 mismatch... it was showing the wrong unit until I used the -FcUTF8 compile option, then it actually showed what file had '<highbit ascii>' strings ... so I switched to #<byte_number> and it compiles, but, the prompts have "D" at the start of them now. (hopefully I described that understandable). Environment: Windows XP 32bit C:\FPC\3.0.4\bin\i386-Win32\fpc.exe If no one else has experienced/has a solution, I will sit down and bang out test cases until I find what combination (units, code, whatever) is producing this result. Ozz _______________________________________________ fpc-devel maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email

Gerhard Scholz
to Ozz Nixon: Sure! I assume you are asking how to make a console app? You do not need {$APPTYPE…

(laughter)

I know how to write console apps; I even know how to start them :-) {I have no experience with GUI progarms, but that's another story :-( }

No, my question was: how did you put the "D" in the keyboard buffer? I would like to put out the next command

Earlier message 94 lines
----- Original Message ----- From: Ozz Nixon To: Gerhard Scholz Cc: FPC developers' list Sent: Sunday, April 26, 2020 8:31 AM Subject: Re: [fpc-devel] Windows Console App Sure! I assume you are asking how to make a console app? You do not need {$APPTYPE CONSOLE} ... instead, you simply write your code like normal: Program example; Uses CRT; Begin ClrScr; Writeln('Wassup?!'); Readln; End. then in the command prompt (any OS), simply fpc example .... then .\example, or ./example - depending upon your OS... voila. "Console App".... now, that is not a DOS 16bit APP... that requires other mess, and since I own Turbo Pascal 7.0 source, I have my own TP 32bit compiler that produces TP 7 compatible 16bit Units and Apps. ;-) @ you can get me at if you need any help (I do not normally code GUI apps - money in the Legacy market) so I have made a wide range of solutions. This email was started because of something odd on Windows recently for me... Ozz On Sun, Apr 26, 2020 at 1:27 AM Gerhard Scholz wrote: Hi, I would like to know how you did that since it was exactly what I was searchomg for a while ago... Could you send me a piece of code? Greetings Gerhard ----- Original Message ----- From: Ozz Nixon via fpc-devel To: FPC developers' list Cc: Ozz Nixon Sent: Sunday, April 26, 2020 2:21 AM Subject: [fpc-devel] Windows Console App Anyone ever experience making a console app (cross-platform), but, on windows when the app finishes, it appears to have put an uppercase C or D in the keyboard buffer, so the Prompt now has C:\>D<cursor> ??? Every time I run my app, be it show help screen and end, or actually execute - when it finishes I end up with a letter sitting at the prompt. (A few months ago, I was having a problem, and it was related to compiling all of the methods with cdecl. That build would leave a stray "C" at the start of the prompt upon exiting. Now, I ran into a new problem where I needed to recompile with -FcUTF8 to track down which units it thought were having a UTF-8 mismatch... it was showing the wrong unit until I used the -FcUTF8 compile option, then it actually showed what file had '<highbit ascii>' strings ... so I switched to #<byte_number> and it compiles, but, the prompts have "D" at the start of them now. (hopefully I described that understandable). Environment: Windows XP 32bit C:\FPC\3.0.4\bin\i386-Win32\fpc.exe If no one else has experienced/has a solution, I will sit down and bang out test cases until I find what combination (units, code, whatever) is producing this result. Ozz

Reply by email

Ozz Nixon
to Gerhard Scholz

Lol. That is not being done on purpose.

To do it on purpose there are different ways depending upon your OS - windows I assume?

keybd_event(Ord('A'), 0, KEYEVENTF_KEYDOWN, 0);
keybd_event(Ord('A'), 0, KEYEVENTF_KEYUP, 0);

* Common mistake is to call it once, it must be both for it to register. (this is from some OLD code)... looking at FPC's site - keybd_event is deprecated.

This pay work:
https://wiki.freepascal.org/MouseAndKeyInput

 KeyInput.Apply([ssCtrl]);
 KeyInput.Press(VK_F1);                // This will simulate press of
F1 function key.
 KeyInput.Unapply([ssCtrl]);

** Uses: MouseAndKeyInput, LCLType,

FROM LAZARUS being installed.

AM Gerhard Scholz wrote 111 lines
(laughter) I know how to write console apps; I even know how to start them :-) {I have no experience with GUI progarms, but that's another story :-( } No, my question was: how did you put the "D" in the keyboard buffer? I would like to put out the next command ----- Original Message ----- From: Ozz Nixon To: Gerhard Scholz Cc: FPC developers' list Sent: Sunday, April 26, 2020 8:31 AM Subject: Re: [fpc-devel] Windows Console App Sure! I assume you are asking how to make a console app? You do not need {$APPTYPE CONSOLE} ... instead, you simply write your code like normal: Program example; Uses CRT; Begin ClrScr; Writeln('Wassup?!'); Readln; End. then in the command prompt (any OS), simply fpc example .... then .\example, or ./example - depending upon your OS... voila. "Console App".... now, that is not a DOS 16bit APP... that requires other mess, and since I own Turbo Pascal 7.0 source, I have my own TP 32bit compiler that produces TP 7 compatible 16bit Units and Apps. ;-) @ you can get me at if you need any help (I do not normally code GUI apps - money in the Legacy market) so I have made a wide range of solutions. This email was started because of something odd on Windows recently for me... Ozz On Sun, Apr 26, 2020 at 1:27 AM Gerhard Scholz wrote: Hi, I would like to know how you did that since it was exactly what I was searchomg for a while ago... Could you send me a piece of code? Greetings Gerhard ----- Original Message ----- From: Ozz Nixon via fpc-devel To: FPC developers' list Cc: Ozz Nixon Sent: Sunday, April 26, 2020 2:21 AM Subject: [fpc-devel] Windows Console App Anyone ever experience making a console app (cross-platform), but, on windows when the app finishes, it appears to have put an uppercase C or D in the keyboard buffer, so the Prompt now has C:\>D<cursor> ??? Every time I run my app, be it show help screen and end, or actually execute - when it finishes I end up with a letter sitting at the prompt. (A few months ago, I was having a problem, and it was related to compiling all of the methods with cdecl. That build would leave a stray "C" at the start of the prompt upon exiting. Now, I ran into a new problem where I needed to recompile with -FcUTF8 to track down which units it thought were having a UTF-8 mismatch... it was showing the wrong unit until I used the -FcUTF8 compile option, then it actually showed what file had '<highbit ascii>' strings ... so I switched to #<byte_number> and it compiles, but, the prompts have "D" at the start of them now. (hopefully I described that understandable). Environment: Windows XP 32bit C:\FPC\3.0.4\bin\i386-Win32\fpc.exe If no one else has experienced/has a solution, I will sit down and bang out test cases until I find what combination (units, code, whatever) is producing this result. Ozz _______________________________________________ fpc-devel maillist - https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel

Reply by email