Virtual Pascal

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.

Views: 72

Reply to This

Replies to This Discussion

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):

  1. Use Crt (as mentioned by you).
  2. Use Drivers from Turbo Vision.
  3. Use target platform specific (OS API) calls.

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

{$ifdef asm}
hacked-to-pieces assembler as generated by the compiler
{$else}
Old working Pascal

{$endif}

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

const
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:

(*
* UPDATE_LIST_POINTERS:
*
* const
* xyz_ptr: xyzptr = nil;
* xyz_top: xyzptr = nil;
* xyz_end: xyzptr = nil;
*
* Called as:
*
* update_list_pointers(xyz_ptr);
*
* Replaces:
*
* if xyz_top = nil then
* xyz_top:= xyz_ptr
* else
* xyz_end^.xyz_nxt:= xyz_ptr;
*
* xyz_end:= xyz_ptr;
*)
type
any_rec = record
any_ptr: anyptr;
any_top: anyptr;
any_end: anyptr;
end;
procedure update_list_pointers(var p);
var _p: any_rec absolute p; begin
if _p.any_top = nil then
_p.any_top:= _p.any_ptr
else
_p.any_end^.any_nxt:= _p.any_ptr;
_p.any_end:= _p.any_ptr;
end; {update_list_pointers}

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 ;-) ).

RSS

© 2021   Created by Allan Mertner.   Powered by

Report an Issue  |  Terms of Service