home *** CD-ROM | disk | FTP | other *** search
- {
- Copyright (c) 1988 BittWare Computing, ALL RIGHTS RESERVED
- }
- unit beepkey4;
- interface
-
- uses
- menuvars,
- crt;
-
- const
- {coded constants}
- func_key = 0;
- carr_rtn = 1;
- valid_num = 2;
- lt_arr = 4;
- rt_arr = 5;
- up_arr = 6;
- dn_arr = 7;
- fn_home = 8;
- fn_end = 9;
- fn_pgdn = 10;
- fn_pgup = 11;
- escape = 12;
- back_spc = 13;
- ch_i = 14;
- ch_o = 15;
- ch_r = 16;
- ch_s = 17;
- ch_t = 18;
- space = 20;
- f1 = 21;
- f2 = 22;
- f3 = 23;
- f4 = 24;
- f5 = 25;
- f6 = 26;
- f7 = 27;
- f8 = 28;
- f9 = 29;
- f10 = 30;
- sh_lt_arr = 31;
- sh_rt_arr = 32;
- ctl_rt_arr = 33;
- ctl_lt_arr = 34;
- plus_key = 35;
- minus_key = 36;
- HotKey = 37;
- UnSuppFuncKey = 38;
- InsKey = 39;
- DelKey = 40;
- other_ch = 255;
-
- lt_arr_asc = 'K';
- rt_arr_asc = 'M';
- up_arr_asc = 'H';
- dn_arr_asc = 'P';
- fn_end_asc = 'O';
- fn_home_asc = 'G';
- fn_pgdn_asc = 'I';
- fn_pgup_asc = 'Q';
- f1_asc = ';';
- f2_asc = '<';
- f3_asc = '=';
- f4_asc = '>';
- f5_asc = '?';
- f6_asc = '@';
- f7_asc = 'A';
- f8_asc = 'B';
- f9_asc = 'C';
- f10_asc = 'D';
- ins_asc = 'R';
- del_asc = 'S';
- ctl_lt_asc = 's';
- ctl_rt_asc = 't';
- back_spc_asc = '';
-
- type
- linestring = string[80];
- {
- ch_set = set of char;
- }
-
- var
- func_key_bool :boolean;
- indx :integer;
-
- procedure DelayOrKey(Pause:integer);
- procedure inkey(char_set:ch_set;var ch:char);
- procedure in_carr_rtn;
- procedure InEsc;
- procedure in_space;
- procedure up_case_func(var in_str:linestring);
- procedure bad_beep;
- procedure good_beep;
-
- implementation
-
- procedure good_beep;
- begin
- sound(700);
- delay(30);
- nosound
- end;
-
- procedure bad_beep;
- begin
- sound(200);
- delay(150);
- nosound
- end;
-
- procedure DelayOrKey(Pause:integer);
- var
- ch :char;
- indx :integer;
- begin
- indx := 0;
- repeat
- delay(20);
- inc(indx);
- until((indx=pause) or KeyPressed);
- if KeyPressed then
- repeat
- ch := readkey;
- until(not(KeyPressed));
- end;
-
- procedure up_case_func(var in_str:linestring);
- var
- ch :string[1];
- begin
- for indx := 1 to length(in_str) do begin
- ch := copy(in_str,indx,1);
- delete(in_str,indx,1);
- insert(upcase(ch[1]),in_str,indx);
- end;
- end;
-
- procedure in_space;
- var
- ch:char;
- begin
- repeat
- ch := readkey;
- if ch <> ' ' then bad_beep;
- until ch = ' ';
- end;
-
- procedure in_carr_rtn;
- var
- ch:char;
- begin
- repeat
- ch := readkey;
- if ch <> #13 then bad_beep;
- until ch = #13;
- end;
-
- procedure InEsc;
- var
- ch:char;
- begin
- repeat
- ch := readkey;
- if ch <> #27 then bad_beep;
- until ch = #27;
- end;
-
- procedure inkey(char_set:ch_set;var ch:char);
- begin
- repeat
- ch := readkey;
- ch := upcase(ch);
- if not (ch in char_set) then begin
- if ch=#0 then begin
- ch := readkey;
- ch := #255;
- end;
- bad_beep;
- end;
- until ch in char_set;
- end;
-
- end.
-