home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 September / Chip_1999-09_cd.bin / internet / Jeremy / tp / downloads / keybar.pas < prev    next >
Pascal/Delphi Source File  |  1999-08-03  |  2KB  |  77 lines

  1. unit keybar;
  2. interface
  3.  
  4. procedure ReadKb(Klavesa, popis: string; znak: char; prikaz: word);
  5. function GetKeyBar: word;
  6.  
  7. implementation
  8. uses crt,vstupsav;
  9.  
  10.  var
  11.     keys: array [1..12] of record
  12.                            KKlavesa: string[5];
  13.                            KPopis: string[10];
  14.                            KZnak: char;
  15.                            KPrikaz: word;
  16.                            end;
  17.  
  18.  const
  19.       KbCount: byte = 0;
  20.       Keybs: set of char = [];
  21.       StartPosKb: byte = 4;
  22.       KbCode=16*7+yellow;
  23.       KbPopis=16*7+white;
  24.       KbStand=16*7+black;
  25.  
  26. procedure ReadKb(Klavesa, popis: string; znak: char; prikaz: word);
  27. begin
  28.      KbCount:=KbCount+1;
  29.      Keys[KbCount].KKlavesa:=klavesa;
  30.      Keys[KbCount].KPopis:=Popis;
  31.      Keys[KbCount].KZnak:=znak;
  32.      Keys[KbCount].KPrikaz:=prikaz;
  33.      Keybs:=Keybs+[znak];
  34. end;
  35.  
  36. procedure KbNul;
  37. begin
  38.      KbCount:=0;
  39.      StartPosKb:=4;
  40.      Keybs:=[];
  41. end;
  42.  
  43. function GetKeyBar: word;
  44. var
  45.    I,J,maxX: byte;
  46.    key: char;
  47. begin
  48.      gotoxy(StartPosKb,25);
  49.      for I:=1 to KbCount do
  50.       begin
  51.            textattr:=KbCode;
  52.            write(keys[I].KKlavesa,' ');
  53.            textattr:=KbPopis;
  54.            write(keys[I].KPopis);
  55.            gotoxy(wherex+1,25);
  56.       end;
  57.      {maxX:=wherex;}
  58.      key:=GetLegalKey(keybs);
  59.      for I:=1 to kbCount do
  60.       begin
  61.            if key=keys[I].KZnak then
  62.             begin
  63.                  GetKeyBar:=keys[I].KPrikaz;
  64.                  textattr:=kbStand;
  65.                  for J:=StartPosKb to 78 do
  66.                   begin
  67.                        gotoxy(j,25);
  68.                        write(#205);
  69.                   end;
  70.                  KbNul;
  71.                  exit;
  72.             end;
  73.       end;
  74. end;
  75.  
  76. BEGIN
  77. END.