home *** CD-ROM | disk | FTP | other *** search
- Function Keys
- ─────────────
-
- WMmain, WMmenu, WM Read, WM WAView and WM PRGed all give you access to ten
- programmable Function keys (F1 to F10). In addition, many WM application
- programs change the contents of WAVmaker's public Function key file (see
- below), allowing new Function key values to be inherited by other WM
- applications (this is actually the ONLY mechanism available for changing
- Function key values in WMmain and in WMmenu!).
-
- Details about Function key operations in individual programs can be found in
- the respective Help entries. See in particular {menuCmnd}, {Read}, {WAView}
- and {PRGed}.
-
- This document explains the generic mechanisms behind WAVmaker's Function key
- operations.
-
- Contents: ■ Titles and Values {FnKeys 24}
- ──────── ■ Private Function key files {FnKeys 41}
- ■ The Public function key file {FnKeys 77}
- ■ Is this a kludge or what?!? {FnKeys 140} (want to speed it up?)
-
-
- ─── Titles and Values ──────────────────────────────────────────────────────────
-
- At runtime, all WAVmaker applications supporting Function keys keep their own
- private record of current Function key titles and values. These are strings
- comprised of up to 15 characters each (reflecting the length of the standard
- DOS keyboard buffer).
-
- ■ Titles are labels, preferably mnemonic ones. Typical titles are "File #1",
- "Start time" or, when greater flexibility is called for, "Parameter #1".
- There is nothing to keep you from assigning a time value to a Function
- entitled "File #1", but if you can refrain from doing so, you probably
- should!
-
- ■ Values are what gets actually written to the keyboard buffer when you press
- a Function key.
-
-
- ─── Private Function key files ─────────────────────────────────────────────────
-
- Some WAVmaker programs keep private files where they store current Function
- key titles and values upon exit. The next time such a program is called, the
- file is read back in and the Function key assignments are updated accordingly.
- WMmain and WMmenu do this, for instance, allowing you to switch back and forth
- between menus and have a different set of Function key assignments for each
- one of them (WMmenu maintains a separate file for each menu it manages, so
- there is no risk of interference between Function key assignment for e.g.
- the File and the PRG menus - but see the explanation of inheritance, below
- {FnKeys 77}).
-
- If you take a look at WM.BAT, you will see that WMmain is started with the
- option "/TD <directory>"; "TD" stands for "Temporary Directory", <directory>
- denotes the directory where all private Function key files (among other
- things) are kept during a WAVmaker session. WAVmaker applications which use
- such files should be provided with a "/TD <directory>" command line pair by
- the caller. WMmain and WMmenu take care of this automagically by prefixing
- the user-supplied command line with the correct "/TD <directory>" pair before
- launching an application requiring it, making the process transparent to the
- user. For details on how to tell WMmain and WMmenu when such special treatment
- is required, see {Customiz}.
-
- If a WAVmaker application requiring a "/TD <directory>" command line pair is
- started up without one, it will neither read from nor write to the public
- Function key file. The only exceptions are WMmain and WMmenu, which default
- to "/TD Temp\". Since the <directory> fed to WMmain is propagated down to all
- other WAVmaker applications (WMmain calls WMmenu with the "/TD <directory>"
- option, too!), starting WMmain without a "/TD <directory>" pair will cause all
- WAVmaker applications to use the Temp\ directory for their private Function
- key files (and for other things, too). The <directory> propagated to other
- programs by WMmain and WMmenu is actually a fully expanded path, complete with
- disk drive, so there is no risk of errors if the program works somewhere else
- than in WAVmaker's main directory.
-
-
- ─── The Public Function key file ───────────────────────────────────────────────
-
- If there were only runtime memory records and private files of Function key
- assignments, the assignments for each WAVmaker application would be totally
- isolated from those for all others. In practice, the main purpose of Function
- keys in WAVmaker is not so much to aid your memory (and typing) as to provide
- a simple means for inter-application communication (now THAT came out sounding
- quite impressive, didn't it?).
-
- When WMmain and WMmenu are instructed to pass the "/TD <directory>" command
- line pair described above {FnKeys 53}, they also assume that the program
- being lauched may need to know some (or all) current Function key values,
- and to return new ones upon termination. All WAVmaker applications which
- import and export Function key assignments do so by reading from and writing
- to the public Function key file (FnDelta.TXT, residing in whichever directory
- is specified by the /TD option). Thus, when WMmain and WMmenu are instructed
- to call a program requiring a "/TD <directory>" pair, they write all their
- current Function key assignments to the public Function key file before
- executing the call. It is then up to the program being launched to read from
- the file (if needed), and (optionally) to modify the same file upon
- termination.
-
- The actual contents of the public Function key file is always a number of
- title:value pairs; first a line specifying a title (e.g. "File #1"), then a
- line specifying a value (e.g. "TEST.MID").
-
- When control is returned to WMmain or WMmenu after a call to a program
- requiring a "/TD <directory>" pair, the public Function key file is read,
- and the values of Function keys with matching titles are updated. What counts
- here is TITLES, not key numbers; the latter are not even exported, i.e. there
- is no way to tell which Function key was assigned a certain title:value by
- reading the public Function key file. Most WAVmaker applications import
- Function key values by running through the file and comparing titles with
- those currently assigned to the Function keys. When a match is found, the
- new value is read in. (WM Read is an exception to this rule: it reads in
- all it finds, in the order it's found, both titles and values, thus inheriting
- the exact Function key map written to the public Function key file by the
- caller).
-
- Note: WMmenu always reads the public Function key file upon startup, and
- it always dumps its current Function key map back into the public
- Function key file upon termination. The public file is read after the
- private one, so new values inherited from WMmain override old ones
- saved to the private file during earlier runs.
-
- To WMmain, WMmenu is just another application requiring a
- "/TD <directory>" pair. Upon return from WMmenu, WMmain will
- therefore scan the public Function key file for matching titles
- and update its own Function key values according to the above
- description {FnKeys 103}: in this case, communication works both
- ways.
-
- In other words, if your main menu has a Function key entitled
- "File #1", and you enter a submenu with a Function key having the
- same title, hitting that key should always give the same result in
- both menus.
-
- WARNING: CASE MATTERS ("File #1" is NOT the same as "FILE #1"). Be careful
- when you assign Function key titles, or you may end up having
- apparently mysterious errors with Function keys refusing to inherit
- new values!
-
-
- ─── Is this a kludge or what?!? ────────────────────────────────────────────────
-
- In a way, it is. Passing values over a disk file is not very elegant, and
- it can be slow. If you are a programmer, you're probably wondering why
- WAVmaker does not use a common memory area for its "clipboard". The reason
- is very simple: WAVmaker is meant to be easily extended, by anyone, by any
- means. Reading and writing text files is as easy as it gets; even a BAT will
- manage that. Passing a memory address between applications is easy too, but
- it takes an experienced programmer to put such an address to good use, and
- BATs will no longer do - you'll need a compiler.
-
- Actually, with a fast hard disk (and especially with a good disk cache) the
- time spent reading and writing Function key files is barely noticeable.
- Should you nevertheless be bothered by a slight delay when switching menus,
- try putting your /TD directory on a RAM disk (since the files are quite small,
- a minimal RAM disk will do - 10 kB or so should be fine). This in combination
- with XMS swapping should make your menus switch like greased lightning! See
- {Customiz} for details.