(LOGO.JPG) Python for OpenVMS

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


READ_STRING - Read String

Read a string from a virtual keyboard.

Format:

    status, resultant_string,                                 \
    terminator_code, terminator_string =                      \
        vms_smg.read_string (keyboard_id, [prompt_string],    \
            [maximum_length], [modifiers], [timeout],         \
            [terminator_set], [display_id], [initial_string], \
            [rendition_set], [rendition_complement])
Returns:
status
Condition code as returned from SMG$READ_STRING. You need to check it yourself.
resultant_string
String into which the input line is written.
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'.
terminator_string
Characters that terminated I/O. These are the actual terminating characters, not the key that was pressed to terminate the I/O.
Arguments:
keyboard_id
The identifier of the virtual keyboard from which to read.
prompt_string
The prompt for the read operation.
maximum_length
The maximum number of characters to be read. The maximum valid value for this argument is 512. If omitted, 512 is the default. This is not enforced by the Python interface routine.
modifiers
Bit mask that specifies optional behavior. Values like TRM_M_TM_CVTLOW are in module 'vms_trmdef'.
timeout
Timeout count. If specified, any character typed before the timeout is returned in the buffer.
terminator_set
Either a mask that specifies which characters are to be treated as terminators (short form) or a descriptor pointing to such a mask (long form).

The Python interface uses a Python integer for the short form terminator and a Python string for the long form.

@@ This part needs further investigation.

display_id
See the OpenVMS documentation for details.
initial_string
Initial character string that is put into the field as if the string has been entered from the keyboard. 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 string
>>> status, resultant_string,                       \
...   terminator_code, terminator_string =          \
...       vms_smg.read_string (keyboard_id, 'IN=',  \
...           5, None, None,                        \
...           None, vtdpy1, 'AB',                   \
...           None, None)

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

Screen layout, file: VMS_SMG_065.JPG

(picture VMS_SMG_065.JPG)

'AB' is pre-loaded into the input buffer.
'B' is deleted by hitting the [DEL] key.
'C' is entered.
Input is terminated by hitting the [PF4] key.

Notice that the Python interpreter returns with the prompt:

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

>>> print repr(resultant_string)
'AC'
>>> print terminator_code, vms_smgdef.SMG_K_TRM_PF4
259 259
>>> print repr(terminator_string)
'\033OS'
>>> # '\033' is ESC
>>>

>>> # use a timeout of 3 seconds
>>> status, resultant_string,                 \
... terminator_code, terminator_string =      \
... vms_smg.read_string (keyboard_id, 'IN=',  \
... 5, None, 3,                               \
... None, vtdpy1, 'AB',                       \
... None, None)
>>> print vms_sys.getmsg (status)[0]
%SYSTEM-F-TIMEOUT, device timeout
>>>

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

11-SEP-2000 ZE.