home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Utilities / QuickFile / ARexx / FKey.quickfile < prev    next >
Text File  |  2000-05-27  |  3KB  |  92 lines

  1. /*
  2. $VER: FKey.quickfile 1.5 (27 May 2000  23:27:22) By M Andre Z Eckenrode
  3.  
  4. Launches database/window-specific macros from function keys, with or
  5. without a qualifier key.
  6.  
  7. Requires an argument string containing the name of the function key, or the
  8. names of the qualifier and function keys separated by a dash, used to invoke
  9. this macro, as follows:
  10.  
  11.   <qualifier>-<functionkey>
  12.  
  13. The argument may entered in any case. Available qualifier key descriptions
  14. are SHIFT, CTRL and ALT. For example:
  15.  
  16.   call fkey f1
  17.   call fkey shift-f3
  18.   call fkey ctrl-f7
  19.   call fkey alt-f10
  20.  
  21. This macro opens and reads lines from a file named '<databasename>.keys' (if
  22. it exists) in the current database's home directory, or
  23. 'QuickFileWindow.keys' if the current window is empty (does not have a
  24. database open in it). The respective file should be composed of function key
  25. configurations, and may be easily created by selecting the SAVE AS button in
  26. QuickFile's FUNCTION KEY requester. The arguments to this macro need not be
  27. entered in the same case as the key configuration descriptions, but they
  28. must otherwise match.
  29.  
  30. If a configuration is located for the respective key combination, the specified
  31. command or file macro is executed, unless the macro specified is this one
  32. (if 'FKEY' appears anywhere in the command string), in which case a requester
  33. is displayed to notify the user and execution is halted.
  34.  
  35. Some database/window configuration examples:
  36.  
  37.   'QuickFileWindow.keys' entries
  38.   ==============================================
  39.   F1=openfile 'Examples/AddressBook/AddressBook'
  40.   F2=openfile 'Examples/Images/Images'
  41.   F3=openfile 'Examples/Library/Library'
  42.  
  43.   'AddressBook.keys' entries
  44.   ==============================================
  45.   F1=setview 'AddressBook.View'
  46.   F2=setview 'AddrLabels.View'
  47.   F3=setview 'AddrList.View'
  48.   Shift-F10='call demo'
  49.  
  50. */
  51.  
  52. options results
  53. key = upper(arg(1))'='
  54.  
  55. setfile
  56. db = result
  57. if db ~== '' then query file 'DB' db
  58. else do
  59.     db.path = pragma('d')
  60.     db = 'QuickFileWindow'
  61. end
  62. call pragma('d',db.path)
  63. home = result
  64. db.keys = pragma('d')||copies('/',abs(sign(pos(':',pragma('d'),length(pragma('d'))))-1))db'.keys'
  65. call pragma('d',home)
  66.  
  67. if ~exists(db.keys) then do
  68.     reqmsg '"File\010\039'db.keys'\039not found"'
  69.     exit
  70. end
  71.  
  72. if ~open(1keys,db.keys,'r') then do
  73.     reqmsg '"Unable to open file\010\039'db.keys'\039."'
  74.     exit
  75. end
  76.  
  77. len = length(key)
  78. exe = 0
  79. do until eof(1keys) | upper(left(config,len)) = key
  80.     config = readln(1keys)
  81.     if upper(left(config,len)) = key then do
  82.         cmd = delstr(config,1,len)
  83.         exe = 1
  84.         if pos('FKEY',upper(cmd)) > 0 then do
  85.             reqmsg '"Call to macro \039FKey.quickfile\039 detected in file\010\039'db.keys'\039.\010Execution halted"'
  86.             exit
  87.         end
  88.         interpret cmd
  89.     end
  90. end
  91. if exe = 0 then reqmsg '"No configuration found for key \039'left(key,len-1)'\039 in file\010\039'db.keys'\039."'
  92.