These procedures and functions provide access to the BASIC keyboard and CRT through the KBDCRT module. The capabilities provided include:
The CRT I/O routines access the CRT drivers at a fairly low-level. For example, the scrolling routines and disp_at_xy are below the high-level PRINT driver. Therefore, system variables defining the top and bottom of current text, and current print position are not updated by these routines. This leads to what appears to be abnormal behavior in arrow key scrolling and current print position. Consequently, it is recommended these procedures not be used when mixing CSUB displays with normal BASIC displays. Instead, use write and writeln.
This appendix is a reference that describes in detail each procedure and function. For an overview of this information, see the chapter "I/O From CSUBs," section "Keyboard and CRT I/O."
IMPORT: | KBDCRT |
This procedure clears the alpha CRT, which is exactly the same as the [Clear display] key on the keyboard, or the BASIC CLEAR SCREEN statement.
CLEAR_SCREEN <\memo>
CLEAR_SCREEN
IF finished THEN CLEAR_SCREEN
IMPORT: | KBDCRT |
This procedure sends information to a CRT control register.
CONTROLCRT ( register number, control )
Item | Description | Range |
---|---|---|
register number | numeric expression of TYPE cbyte | 0 to 21 except for 3,6,7,9, and 19. |
control | numeric expression of TYPE cword | depends on the register |
CONTROLCRT(reg, cont)
CONTROLCRT(1,10)
The "register number" (reg) parameter designates the register to be written.
The "control" (cont) contains the value to be written into the CRT control register. Refer to the "CRT Status and Control Registers" section under the "Interface Registers" tab in the BASIC Language Reference for more information.
This procedure will escape with a BASIC errorcode if an illegal argument is given. The value will be such that errorcode MOD 1000 = 401 is true.
IMPORT: | KBDCRT |
This procedure sends information to a keyboard control register.
CONTROLKBD ( register number , control )
Item | Description | Range |
---|---|---|
register number | numeric expression of TYPE cbyte | 0 to 17 except for 5,6,8,9 and 10 |
control | numeric expression of TYPE cword | depends on register |
CONTROLKBD(reg, cont)
CONTROLKBD(2,0)
The "register number" (reg) parameter designates the register to be written.
The "control" (cont) contains the value to be written into the keyboard control register. Refer to the "Keyboard Status and Control Registers" section under the "Interface Registers" tab in the BASIC Language Reference for more information.
This procedure will escape with a BASIC errorcode if an illegal argument is given. The value will be such that errorcode MOD 1000 = 401 is true.
IMPORT: | KBDCRT |
This function reads one character from the specified location on the CRT.
CRTREADCHAR ( x_coordinate , y_coordinate )
Item | Description | Range |
---|---|---|
x_coordinate | numeric expression of TYPE cbyte | 1 to screen width |
y_coordinate word | numeric expression of TYPE cbyte | 1 to screen height |
FUNCTION CRTREADCHAR (X,Y:CBYTE): CHAR;
One_chr := CRTREADCHAR(xcrd,ycrd)
IF CRTREADCHAR(24,22) = 'A' THEN foundit := TRUE
The "x_coordinate" (xcrd) and "y_coordinate" (ycrd) specify the on-screen alpha location from the upper left corner of the alpha CRT area (affected by ALPHA HEIGHT). Invalid values of x,y result in an escape with escapecode set to 1019.
IMPORT: | KBDCRT |
This procedure scrolls the CRT area from line first to line last up or down one line.
CRTSCROLL ( first line, lastline , down )
Item | Description | Range |
---|---|---|
first line | numeric expression of TYPE cbyte | 1 thru screen height |
last line | numeric expression of TYPE cbyte | 1 thru screen height |
boolean | expression of TYPE boolean | true or false |
CRTSCROLL(first,last,dn)
CRTSCROLL(12,22,tf)
The "first line" (first) parameter signifies the first line.
The "last line" (last) parameter signifies the last line. Lines first and last are relative to the current alpha screen (i.e., modified by ALPHA HEIGHT). Tests are made for 0<first line<last line<=screen height, if they fail, an escape(1019) occurs.
These routines do not scroll text to/from the offscreen alpha buffer (if any) which the system uses. Instead, they clear the first or last line of the scrolling region.
The "down" (dn) parameter signifies whether to scroll up or down one line. That is, if down (dn) is false, it scrolls this area up one line.
IMPORT: | KBDCRT |
This procedure removes the previous cursor and writes a new cursor to any on-screen alpha location.
CURSOR ( x_coordinate , y_coordinate , cursorstate )
Item | Description | Range |
---|---|---|
x_coordinate | numeric expression of TYPE cbyte | 1 thru screen width |
y_coordinate | numeric expression of TYPE cbyte | 1 thru screen height |
cursorstate | expression of TYPE cursortype | normal_cursor, insert_cursor, or off_cursor |
CURSOR(xcrd,ycrd,ctype)
CURSOR(24,22,normalcursor)
The "x_coordinate" (xcrd) and "y_coordinate" (ycrd) specify the on-screen alpha location of the cursor from the upper left corner of the alpha CRT area (affected by ALPHA HEIGHT).
Any system action which moves the cursor will overwrite the action of this procedure. This includes any key press if not trapped by ON KBD. The programmer must take this into account in using this feature.
The possible values of "cursorstate" (ctype) are normal_cursor, insert_cursor, and off_cursor.
IMPORT: | KBDCRT |
This procedure writes text to any on-screen alpha location.
DISP_AT_XY ( x_coordinate , y_coordinate , bufstring , parseflag , enhance )
Item | Description | Range |
---|---|---|
x_coordinate | numeric expression of TYPE cbyte | 1 thru screen width |
y_coordinate | numeric expression of TYPE cbyte | 1 thru screen height |
bufstring | expression of TYPE kbd_string | |
packed record len: string; c: packed array [1..256] of char; end; | within range of kbd_string | |
parseflag | numeric expression of TYPE boolean | true or false |
enhance | expression of TYPE enhtype | |
packed record color : cbyte; hilite : cbyte; end; | within range of enhtype |
DISP_AT_XY(xcrd, ycrd, var_str, parse, var_enhc)
DISP_AT_XY(22, 34, strrecord, tf, enhcrecord)
disp_at_xy can be used to put characters anywhere on the screen including the areas which are normally the keyboard lines, key labels, etc. This does not put those characters into the keyboard buffer, or any other internal buffer related to those areas. Specifically, it does not do an OUTPUT KBD. They will, however, be re-displayed by a GCLEAR on a bit-mapped display.
The "x_coordinate" (xcrd) and "y_coordinate" (ycrd) specify the on-screen alpha location of the cursor from the upper left corner of the alpha CRT area (affected by ALPHA HEIGHT). Characters will be wrapped at the alpha CRT width (not necessarily the PRINTER IS;WIDTH). A check is made for strings which would run off the end of the display. Out of range values of x and y are mapped to 1,1 and strings that are too long are truncated.
The "parseflag" (parse) parameter indicates whether characters in the range 128..143 are to be interpreted as highlights or displayed as characters. It also affects the display of characters 144..159; characters 0..31 are always displayed.
The "bufstring" (var_str) parameter contains the text to be written to the screen.
The "enhance" (var_enhc) parameter specifies the color and highlights for the text. It should be initialized to an appropriate value. However, internal color values for ALPHA PEN 1..7 may be different from the user specified value. For ALPHA PENs above 7 the value of color is the pen number. The highlight values are also encoded. The simplest way to initialize enhc for highlights and for colors less than 8 is to set parseflag to true and print a string with characters in the range 128..143. Then the correct values will be returned in the var parameter var_enhc.
For monochrome displays, the color byte is ignored.
Some localized versions of BASIC, such as Japanese localized BASIC, support two-byte characters. Pascal does not support two-byte characters directly. However, since disp_at_xy actually calls BASIC's internal printing functions, you can include two-byte characters in "bufstring". Note that "x_coordinate" and "y_coordinate" are byte positions on the screen analogous to the PRINT TABXY positions in localized BASIC. For more information about two-byte character handling in BASIC, refer to HP BASIC Programming Techniques, Volume 2: Porting and Globalization.
IMPORT: | KBDCRT |
This function returns the buffer contents trapped and held by ON KBD (same as KBD$).
READ_KBD
READ_KBD
You must execute an ON KBD statement before calling the CSUB. Then any calls to the function read_kbd will return the same data as a call to the BASIC function KBD$ would. Calling this function also clears the KBD$ buffer. Use of this function allows you to poll the keyboard for input while in the CSUB. For the best results, include the ,ALL option in the ON KBD statement. Otherwise, a closure key, such as a typing-aid, causes the keyboard to block until an end-of-line occurs. This will not happen in the CSUB.
NOTE |
---|
Closure keys are system-function keys (as opposed to ASCII-character keys) which are logged and subsequently processed by the BASIC system and therefore, normally "close" subsequent keyboard inputs to the system until fully processed. For further information, see the "Keyboard" chapter of BASIC Interfacing Techniques. |
IMPORT: | KBDCRT |
This procedure scrolls the PRINT area of the CRT down one line.
SCROLLDN
SCROLLDN
IMPORT: | KBDCRT |
This procedure scrolls the PRINT area of the CRT up one line.
SCROLLUP
SCROLLUP
IMPORT: | KBDCRT |
This function returns the contents of a CRT status register.
STATUSCRT ( register number)
Item | Description | Range |
---|---|---|
register number | numeric expression of TYPE cbyte | 0 thru 21 |
FUNCTION STATUSCRT (reg:cbyte) : cword;
St_reg := STATUSCRT(reg_no);
IF STATUSCRT(13) = 9 THEN CONTROLCRT (13,18);
The "register number" (reg_no) parameter designates the register to be read. Refer to the "CRT Status and Control Registers" section under the "Interface Registers" tab in the BASIC Language Reference for more information.
This function will escape with a BASIC errorcode if an illegal argument is given. The value will be such that errorcode MOD 1000 = 401 is true.
IMPORT: | KBDCRT |
This function returns the contents of a keyboard status register.
STATUSKBD ( register number)
Item | Description | Range |
---|---|---|
register number | numeric expression of TYPE cbyte | 0 thru 17 except for 3 and 4 |
FUNCTION STATUSKBD (reg:cbyte) : cword;
Str_reg := STATUSKBD(reg_no);
Fn_key := STATUSKBD(2);
The "register number" (reg_no) parameter designates the register to be read. Refer to the "Keyboard Status and Control Registers" section under the "Interface Registers" tab in the BASIC Language Reference for more information.
This function will escape with a BASIC errorcode if an illegal argument is given. The value will be such that errorcode MOD 1000 = 401 is true.
IMPORT: | KBDCRT |
This function returns a string containing the same results (system status and configuration information) as executing SYSTEM$ with the given argument.
SYSTEMD ( argument )
Item | Description | Range |
---|---|---|
argument | string expression of TYPE STRING[18] (string_18) | any valid SYSTEM$ argument |
FUNCTION SYSTEMD (Request: string_18): string_160;
Some_thing := SYSTEMD (arg)
Or_other := SYSTEMD ("AVAILABLE MEMORY")
The "argument" (arg) is the string containing the argument for the BASIC SYSTEM$ function. If the argument is invalid, the result returned is the string "ERROR 401" (i.e., the function does not escape). The value returned is of TYPE STRING[160].
This provides Security Module and ID PROM access plus many other capabilities. SYSTEM$ is in the BASIC Language Reference for further information.