home *** CD-ROM | disk | FTP | other *** search
- /*
- $VER: FKey.quickfile 1.5 (27 May 2000 23:27:22) By M Andre Z Eckenrode
-
- Launches database/window-specific macros from function keys, with or
- without a qualifier key.
-
- Requires an argument string containing the name of the function key, or the
- names of the qualifier and function keys separated by a dash, used to invoke
- this macro, as follows:
-
- <qualifier>-<functionkey>
-
- The argument may entered in any case. Available qualifier key descriptions
- are SHIFT, CTRL and ALT. For example:
-
- call fkey f1
- call fkey shift-f3
- call fkey ctrl-f7
- call fkey alt-f10
-
- This macro opens and reads lines from a file named '<databasename>.keys' (if
- it exists) in the current database's home directory, or
- 'QuickFileWindow.keys' if the current window is empty (does not have a
- database open in it). The respective file should be composed of function key
- configurations, and may be easily created by selecting the SAVE AS button in
- QuickFile's FUNCTION KEY requester. The arguments to this macro need not be
- entered in the same case as the key configuration descriptions, but they
- must otherwise match.
-
- If a configuration is located for the respective key combination, the specified
- command or file macro is executed, unless the macro specified is this one
- (if 'FKEY' appears anywhere in the command string), in which case a requester
- is displayed to notify the user and execution is halted.
-
- Some database/window configuration examples:
-
- 'QuickFileWindow.keys' entries
- ==============================================
- F1=openfile 'Examples/AddressBook/AddressBook'
- F2=openfile 'Examples/Images/Images'
- F3=openfile 'Examples/Library/Library'
-
- 'AddressBook.keys' entries
- ==============================================
- F1=setview 'AddressBook.View'
- F2=setview 'AddrLabels.View'
- F3=setview 'AddrList.View'
- Shift-F10='call demo'
-
- */
-
- options results
- key = upper(arg(1))'='
-
- setfile
- db = result
- if db ~== '' then query file 'DB' db
- else do
- db.path = pragma('d')
- db = 'QuickFileWindow'
- end
- call pragma('d',db.path)
- home = result
- db.keys = pragma('d')||copies('/',abs(sign(pos(':',pragma('d'),length(pragma('d'))))-1))db'.keys'
- call pragma('d',home)
-
- if ~exists(db.keys) then do
- reqmsg '"File\010\039'db.keys'\039not found"'
- exit
- end
-
- if ~open(1keys,db.keys,'r') then do
- reqmsg '"Unable to open file\010\039'db.keys'\039."'
- exit
- end
-
- len = length(key)
- exe = 0
- do until eof(1keys) | upper(left(config,len)) = key
- config = readln(1keys)
- if upper(left(config,len)) = key then do
- cmd = delstr(config,1,len)
- exe = 1
- if pos('FKEY',upper(cmd)) > 0 then do
- reqmsg '"Call to macro \039FKey.quickfile\039 detected in file\010\039'db.keys'\039.\010Execution halted"'
- exit
- end
- interpret cmd
- end
- end
- if exe = 0 then reqmsg '"No configuration found for key \039'left(key,len-1)'\039 in file\010\039'db.keys'\039."'
-