Classic Object Pascal for free
Does anyone know how to add a small ReadKey function to a program without going through the, remember TP/BP, pulling in the, admittedly more smartlink-friendly, VP CRT unit. All I need is something to detect the PgUp, PgDn and Esc keys to provide some "pageable" help screens, and (optionally) the screen-height, although I could just assume something sensible(?) for the latter.
Which target / operating system? I believe that there are only three options as long as talking about just the VP RTL "out of box" (any other options would be based on one of these three - e.g. FPC provides unit keyboard which might be used with VP with limited effort, but the implementation is obviously still based on the option 3 below):
Platform is Windoze, and if I have to use option 3 (OS API calls), so be it. The program(s) that I need this for are already 99% assembler anyway.
For what it's worth, I use VP to generate working code, and after that the code is forked into
hacked-to-pieces assembler as generated by the compiler
Old working Pascal
And the hacked-to-pieces code contains instructions well past the Pentium, coded as, remember TP3?, "db $xx,$yy,$zz...", with the real instructions as comments, the code generated by VP, and, when I last looked at it, FPC, is still not much better than what BP7 generated more than 25 years ago. And FPC still cannot handle one feature that was already present in TP 1.00, which is that a
lift_ptr list_ptr = nil;
lift_top: list_ptr = nil;
lift_end: list_ptr = nil;
will keep all three variables, although one of them is never explicitly used, as in:
* xyz_ptr: xyzptr = nil;
* xyz_top: xyzptr = nil;
* xyz_end: xyzptr = nil;
* Called as:
* if xyz_top = nil then
* xyz_top:= xyz_ptr
* xyz_end^.xyz_nxt:= xyz_ptr;
* xyz_end:= xyz_ptr;
any_rec = record
procedure update_list_pointers(var p);
var _p: any_rec absolute p; begin
if _p.any_top = nil then
FPC does not and that screws up things big time! (And I don't even want to go into calling the RTL directly in FPC, which is child's-play in VP, or the IDE which still sucks.
I didn't mean to suggest that you should use FPC instead of VP (regardless from what I think about evolution of FPC optimization over time and other things mentioned in your response). I just mentioned that FPC provides a unit doing the thing you asked for without introducing other stuff you might not like, e.g. changing the standard output into direct console I/O, etc., as done by unit Crt. In any case, the MS Win32 API function you probably need is ReadConsoleInput (that's what is used in the background for the FPC unit I mentioned ;-) ).