home *** CD-ROM | disk | FTP | other *** search
/ Power Programming / powerprogramming1994.iso / progtool / pibterm / pibt41s1.arc / DEFINEKY.MOD < prev    next >
Text File  |  1988-02-23  |  3KB  |  62 lines

  1. (*----------------------------------------------------------------------*)
  2. (*            Define_Key --- Define a function/keypad key               *)
  3. (*----------------------------------------------------------------------*)
  4.  
  5. PROCEDURE Define_Key( Key_Name : AnyStr;
  6.                       Key_Text : AnyStr  );
  7.  
  8. (*----------------------------------------------------------------------*)
  9. (*                                                                      *)
  10. (*     Procedure:  Define_Key                                           *)
  11. (*                                                                      *)
  12. (*     Purpose:    Defines a function/keypad key string                 *)
  13. (*                                                                      *)
  14. (*     Calling Sequence:                                                *)
  15. (*                                                                      *)
  16. (*        Define_Key( Key_Name : AnyStr;                                *)
  17. (*                    Key_Text : AnyStr  );                             *)
  18. (*                                                                      *)
  19. (*           Key_Name --- Name of key to define                         *)
  20. (*           Key_Text --- Text of key to be defined                     *)
  21. (*                                                                      *)
  22. (*----------------------------------------------------------------------*)
  23.  
  24. VAR
  25.    Key_Number : INTEGER;
  26.    LKey_Text  : INTEGER;
  27.    LDef       : INTEGER;
  28.  
  29. BEGIN (* Define_Key *)
  30.                                    (* Get index of key *)
  31.  
  32.    Key_Number := Get_Key_Index( Key_Name );
  33.  
  34.                                    (* Insert key text *)
  35.  
  36.    IF ( Key_Number >= 0 ) THEN
  37.       WITH Key_Definitions[Key_Number] DO
  38.          BEGIN
  39.  
  40.             Key_Text  := Read_Ctrls( Key_Text );
  41.             LKey_Text := LENGTH( Key_Text );
  42.  
  43.             IF ( Def = NIL ) THEN
  44.                GETMEM( Def , SUCC( LKey_Text ) );
  45.  
  46.             IF ( Def <> NIL ) THEN
  47.                BEGIN
  48.                   LDef := LENGTH( Def^ );
  49.                   IF ( LKey_Text > LDef ) THEN
  50.                      IF ( ( Key_Number <> BS_Key ) AND
  51.                           ( Key_Number <> Ctrl_BS_Key ) ) THEN
  52.                         BEGIN
  53.                            MyFreeMem( Def , SUCC( LDef ) );
  54.                            GETMEM   ( Def , SUCC( LKey_Text ) );
  55.                         END;
  56.                   IF ( Def <> NIL ) THEN
  57.                      Def^ := Key_Text;
  58.                END;
  59.  
  60.          END;
  61.  
  62. END   (* Define_Key *);