Forum > Beginners

ReadKey... as a Word?

(1/1)

Atreyu:
Hello Pascal masters...

Long story short, I'm converting a huge legacy application written in TP 5.5 over to FPC. I'm in need of a routine that works exactly like ReadKey in the standard FPC CRT unit, but returns Word instead of Char. If ALT or function keys are pressed, I need the routine to set the "Lo" portion of ReadKeyWord to zero and putting the value in the "Hi" portion.

I'm trying to satisfy the following legacy code from my app:

work:=readkeyword;
if lo(work)=0 then
  begin
    ch:=chr(hi(work));
    if ord(ch) in [16..50] then
      altkv:=ord(ch);
      if (*editmode and *) (ord(ch) in [94..103,104..113]) then
      begin
        if ord(ch) in [94..103] then
          mn:=ord(ch)-83
        else
          mn:=ord(ch)-103;
        current_macro:=macros[mn];
        macro_pos:=1;
        if current_macro<>nil then
          inc:=inc
        else
          inc:=chr(0)
      end
    else
     if ord(ch)<128 then
      inc:=chr(ord(ch)+128)
    else
      inc:=chr(0);
  end
else
  inc:=chr(lo(work));
end

taazz:
If I remember correctly readkeyword will convert any pressed key from a byte to a word making sure that if the 1st key read is the extended key the next is placed on the high part of the word in order to avoid running the readkey twice it shouldn't be to hard to duplicate it and no I have no idea if the readkeyword exists in fpc.

Bart:
I used to have a WordKey function in TP way back.
However it was using interrupts to get the key's....
I can try to dig it up if you want to...

You might either take a look at crt unit or kvm (??) unit to see how it polls the OS for keystrokes.

Bart

Navigation

[0] Message Index

Go to full version