(LOGO.JPG) Python for OpenVMS

(go to: table of contents, index, list of vms_smg, prev: READ_FROM_DISPLAY, next: NEXT)


READ_KEYSTROKE - Read a Single Character

Read a keystroke and return that keystroke's terminator code.

Format:

    status, terminator_code = vms_smg.read_keystroke \
          (keyboard_id, [prompt_string], [timeout],  \
          [display_id], [rendition_set], [rendition_complement])
Returns:
status
Condition code as returned from SMG$READ_KEYSTROKE. You need to check it yourself.
terminator_code
Code indicating what character or key terminated the read. Key terminator codes are of the form SMG_K_TRM_keyname. Constants like SMG_K_TRM_F1 are in module 'vms_smgdef'.
Arguments:
keyboard_id
The identifier of the virtual keyboard from which to read.
prompt_string
The prompt for the read operation.
timeout
Timeout count. If specified, any character typed before the timeout is returned in the buffer.
display_id
See the OpenVMS documentation for details.
rendition_set
Attribute specifier. Bit mask values like SMG_M_BOLD are in module 'vms_smgdef'.
rendition_complement
Attribute complement specifier. There are no symbolic names available - please see the OpenVMS documentation for details.
Examples:
>>> import vms_smg
>>> import vms_smgdef

>>> # create a new DECwindows terminal using SMG
>>> status, pasteboard_id, number_of_pasteboard_rows, \
... number_of_pasteboard_columns, type_of_terminal,   \
... device_name = vms_smg.create_pasteboard           \
...   (None, vms_smgdef.SMG_M_WORKSTATION)
>>>

>>> # create a virtual keyboard -
>>> #   use the device name from CREATE_PASTEBOARD
>>> keyboard_id, resultant_filespec = \
...     vms_smg.create_virtual_keyboard (device_name)
>>>

>>> # create virtual display
>>> status, vtdpy1 = vms_smg.create_virtual_display \
...         (8, 10, vms_smgdef.SMG_M_BORDER, None, None)
>>>

>>> # paste virtual display
>>> status = vms_smg.paste_virtual_display \
...          (vtdpy1, pasteboard_id, 3, 5, None)
>>>

>>> # put characters on virtual display
>>> status = vms_smg.put_chars (vtdpy1, '1234567890', 1, 1)
>>> status = vms_smg.put_chars (vtdpy1, 'ABCDEFGHIJ', 2, 1)
>>>

>>> # position cursor 
>>> vms_smg.set_cursor_abs (vtdpy1, 3, 1)
>>>

Screen layout, file: VMS_SMG_063.JPG

(picture VMS_SMG_063.JPG)

>>> # read a single keystroke
>>> status, terminator_code = vms_smg.read_keystroke \
...                           (keyboard_id, 'IN=', None, vtdpy1)

Notice that the Python interpreter does not respond
with the prompt ('>>>').

Screen layout, file: VMS_SMG_064.JPG

(picture VMS_SMG_064.JPG)

Enter 'A' into the DECterm.

Notice that the Python interpreter returns with the prompt:

>>>
>>> # check status
>>> import vms_sys
>>> print vms_sys.getmsg (status)[0]
%SYSTEM-S-NORMAL, normal successful completion
>>>

>>> print terminator_code, chr(terminator_code)
65 A
>>>

>>> # make another read
>>> status, terminator_code = vms_smg.read_keystroke \
...                           (keyboard_id, 'IN=>', None, vtdpy1)

Again, the Python interpreter does not respond
with a prompt ('>>>').

(no screenshot here, 'IN2=' is just placed in the next line)

Hit the [PF1] key on the keypad.

Again, the Python interpreter comes back:

>>>
>>> print vms_sys.getmsg (status)[0]
%SYSTEM-S-NORMAL, normal successful completion
>>>

>>> print terminator_code, vms_smgdef.SMG_K_TRM_PF1
256 256
>>>

(go to: table of contents, index, list of vms_smg, prev: READ_FROM_DISPLAY, next: NEXT)

10-SEP-2000 ZE.