KStat$: Difference between revisions

From BR Wiki
Jump to navigation Jump to search
m (1 revision)
(No difference)

Revision as of 14:11, 15 January 2012

KStat$[(X)[,SEC]]

When used without parameters, the KStat$ internal function will return the most recent keystroke value. When used with the numeric parameter X, KSTAT$ causes Business Rules! to wait for input of the number of keystrokes specified.

KSTAT$ has a second optional numeric parameter denoting the number of seconds to wait for each character. e.g. KSTAT$(1,10) waits up to 10 seconds for 1 character

Comments and Examples

Special keys such as HOME, END and the arrow keys return their control-key equivalents. All keys return a one-character value except the function keys, which return a two-character value.

When X is used and the value is 0, it's the same as KSTAT$ with no parameter. If X is negative, 1 will be used. The dimensioned length of the receiving variable should be at least twice as large as the number passed to prevent a string overflow in the event that all keys pressed are function keys (which return two hex characters instead of one).

In the following example, the use of KSTAT$ in line 100 is preferable to its use in line 300, especially on Unix / Linux terminals. Whereas line 300 ties up the processor as it waits for a keystroke, line 100 idles the task until a key is pressed:

00100 LET X$=KSTAT$(1) ! Wait for 1 keystroke
00300 LET X$=KSTAT$ !:
00400 IF X$="" THEN GOTO 300 ! Wait for keystroke

To determine the standardized Business Rules scancodes, run the following program:

10 LET X$ = KSTAT$(1)
20 PRINT UNHEX$(X$)
30 GOTO 10

Each time you press a key, the scancode for that key is displayed.

Technical Considerations

  1. There are two levels of scancodes: the hardware level and the Business Rules level. If you want to determine the standardized Business Rules scancodes, run the program in the examples section above. In all scancode programs, each time you press a key, the scancode for that key is displayed.
  2. The scancodes from the hardware level are used as input for the wbterm program which defines the scancodes at the Business Rules level. Processing for both levels of scancodes is built into DOS and NetWork versions of Business Rules .