KStat$

From BR Wiki
(Redirected from KSTAT$)
Jump to navigation Jump to search
KSTAT[(<numeric expression>)[,<seconds>]]

When used without parameters, the KStat$ internal function will return any keystrokes entered that were not already processed. When used with the numeric parameter, 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.

Example:

KSTAT$(1,10) ! waits up to 10 seconds for 1 keystroke

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 the numeric value is 0, it's the same as KSTAT$ with no parameter. If it 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 .