home *** CD-ROM | disk | FTP | other *** search
- "Sysinfo"
- Copyright (c) 1988 Nantucket Corp. All rights reserved.
-
-
- Terms:
-
- "Clipper" refers to the Summer87 version of Nantucket's Clipper
- compiler for dBASE. None of this information should be assumed to
- apply to any other version of Clipper.
-
- An "internal" is a function or storage location which is not part of the
- published (or external) specification of a system.
-
- A "key code" is the number used by Clipper to refer to a key on the
- keyboard, ala the INKEY() function.
-
-
-
- Background:
-
- Use of internals is always a tricky subject, and Clipper's open
- architecture compounds the problem, mainly via increased temptation.
- The Clipper runtime support library (CLIPPER.LIB) is a standard Intel
- format library, and no particular attempt is made to conceal the meaning
- of the items within it (although some of them are intrinsically non-
- obvious). If you're good with a debugger, you may have already made
- interesting discoveries. Some Clipper add-on products make use of
- information which the authors have laboriously derived via this method.
-
- Use of internals, however, can be dangerous. They are not explicity
- documented or supported, so you use them at your own risk. Accessing
- them incorrectly can cause unexplained system failure, and Nantucket
- support personnel are not trained to answer questions about them.
-
-
- Version Dependence:
-
- Many of the most coveted pieces of internal information are likely to
- change in future versions of Clipper. There are two main reasons for
- this.
-
- First, Clipper's internal organization tends to change significantly
- from one release to the next. When new, more efficient methods are
- found for achieving some result, they are adopted if they are upwardly
- compatible with the external specification of the system. The need
- to maintain internal compatibility with earlier releases would greatly
- complicate the task of improving the system.
-
- Second, many of the most desired pieces of internal information are
- conceptually bound to the current Clipper/dBASE model of programming.
- In the future, this model may change significantly in order to support
- more powerful development models.
-
- A simple example might be the "insert mode" setting. Most dBASE
- implementations provide a single system-wide insert mode which affects
- keyboard input during several kinds of operations. In Clipper this
- includes both the READing of GETs and input to the MEMOEDIT() function.
- This orientation might change in a future version in order to provide
- more powerful input capabilities. For example, each window defined in
- the system might have its own insert mode setting. Perhaps individual
- GETs would be able to have their own setting! In either case, if you
- were directly reading the current internal insert flag, you might find
- that it no longer existed in such a version, or that its meaning had
- changed considerably.
-
-
-
- So?
-
- Despite the foregoing, there are those cases where access to certain
- global state information is valuable. It may in fact promote better
- program structure (read more modularity) since the ability to preserve
- state information favors the creation of "black box" modules which
- automatically preserve the system state on entry and restore it on
- exit. Certain information of this type has been made available at the
- "surface" level in Clipper (e.g. the SETCOLOR() function). Other
- information is buried in the guts of the system, only visible to late-
- night hackers with symbolic debuggers and lots of coffee.
-
- The "sysinfo" functions are a small set of C-callable functions which
- allow you to interrogate the values of some of Clipper's internal state
- variables. They provide access to some of the most requested internal
- items through a procedural interface.
-
- For the very reasons cited above:
-
- THESE FUNCTIONS ARE VERSION DEPENDENT!
-
- However, since they provide a procedural interface between your program
- and the actual internal values, an equivalent capability (if available)
- in future releases would probably be usable with minimal changes to your
- code. The functions are also "safe." That is, you cannot damage the
- system state by calling them.
-
-
-
- Calling conventions:
-
- Most of the functions allow the examination of the current setting of
- SET commands. Three of them take a single parameter (referred to as
- 'specifier' below) which specifies the SET to be interrogated. The
- file "sysinfo.h" includes a list of #define statements for these
- specifiers. You should use them when calling the functions.
-
-
- _sys_boolean(specifier)
-
- This function returns the current state of a system boolean (ON/OFF)
- variable. If the corresponding SET is "ON", the function returns a
- value of 1 (TRUE). Otherwise, the function returns 0 (FALSE).
-
-
- _sys_int(specifier)
-
- This function returns the current state of SET commands which accept
- a numeric parameter. The current setting is returned as an integer.
-
-
- _sys_string(specifier)
-
- This function returns the current state of SET commands which accept
- a character parameter. The function returns a pointer to a string
- representing the current setting.
-
-
- _setkey_count()
-
- This function returns the number of SET KEY's which are currently
- active. The count is returned as an integer.
-
-
- _setkey_key(ordinal)
-
- This function returns the key code associated with the SET KEY
- specified by 'ordinal'. For example, if there are 10 SET KEY's
- currently active, then _setkey(5) will return the code of the key
- associated with the fifth SET KEY. The value is returned as an
- integer. If 'ordinal' is greater than the number of SET KEY's
- currently active, the function returns zero. Note that adding or
- clearing a SET KEY can cause the ordinal numbers to change, so you
- shouldn't assume they will be the same from one call to the next.
-
-
- _setkey_proc(key_code)
-
- This function returns a pointer to a string containing the name of
- the procedure associated with the specified key code. If the
- specified key is not currently associated with a procedure, the
- function returns a pointer to a null string. For example, if your
- application has executed the statement SET KEY -3 TO HELP then
- _setkey_proc(-3) will return a pointer to a string containing
- "HELP". Note that the parameter is a key code, not the ordinal
- number of a SET KEY.
-
-
-
- Notes:
-
- Those functions which return a character pointer return a pointer to
- a single statically allocated buffer. You should make a copy of the
- information if you wish to preserve it, since subsequent calls will
- overwrite the buffer. Also, changing the contents of this buffer has
- no effect on the actual internal value.
-
- Note that the values can only be interrogated, not set, by these
- functions. The intention is that you use these functions to write
- Clipper-callable functions which return the state information to a
- Clipper function. These higher level functions could save and/or
- restore the state information via normal means.
-
- There are a number of ways to arrange Clipper-callable versions of these
- functions. The example below uses the Extor system and the sysinfo
- functions to fill in an array with the current SET KEY settings. A
- Clipper function could be written which would restore the saved settings
- at some later time.
-
-
-
- Example:
-
- /***
- * fill two arrays with SET KEY information, return SET KEY count
- *
- * example:
- *
- * count = GETKEYS()
- * PRIVATE keys[count], procs[count]
- * GETKEYS(keys, procs)
- *
- */
-
- CLIPPER GETKEYS()
-
- {
- int count;
- int index;
- int key;
- char *proc;
-
-
- count = _setkey_count();
-
- if (ISARRAY(1))
- {
- for (index = 1; index <= count; index++)
- {
- key = _setkey_key(index);
- _storni(key, 1, index);
- }
- }
-
- if (ISARRAY(2))
- {
- for (index = 1; index <= count; index++)
- {
- key = _setkey_key(index);
- proc = _setkey_proc(key);
- _storc(proc, 2, index);
- }
- }
-
- _retni(count);
- }
-
-
-
- Conclusion:
-
- The "sysinfo" functions are useful for creating "black box" modules
- which automatically preserve the application's state on entry and
- restore it on exit. These functions are best used as the low level
- component of a Clipper-callable facility for state preservation and
- restoration.
-
- For some general advice on Clipper-callable functions, please refer to
- the notes in the "readme.doc" file.
-