KStat$: Difference between revisions
No edit summary |
|||
Line 1: | Line 1: | ||
KStat$[( | 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 X, KSTAT$ causes Business Rules! to wait for input of the number of keystrokes specified. | When used without parameters, the '''KStat$''' [[internal function]] will return any keystrokes entered that were not already processed. When used with the numeric parameter X, KSTAT$ causes Business Rules! to wait for input of the number of keystrokes specified. |
Revision as of 19:42, 21 May 2014
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 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.
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 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
- 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.
- 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 .