(go to: table of contents, index, list of VMS objects, prev: vmsobj_xabsum)
It is (currently) not possible to store new data into the buffer with
the setattr mechanism (you cannot do 'membuf.buffer = data').
It is not possible (and will not be) to resize the buffer by assigning
a new value to the 'size' attribute. The reason is that the buffer address
and its length is very likely used by/ stored inside another object (e. g.
vmsobj_rab).
Any arguments to zero() are ignored.
For now the 'pyvms' module contains a function to
explicitly create a vmsobj__membuf object within Python. Note that other
objects - e. g. vmsobj_rab -
can implicitly create a vmsobj__membuf object! See the description of its
"RBF" and
"UBF" attributes.
Examples:
Attributes:
Methods:
>>> # create a new object with pre-defined content
>>> membuf = pyvms.vmsobj__membuf ('abc123')
>>> # show contents
>>> membuf.buffer
'abc123'
>>> # overwrite contents
>>> membuf.zero()
>>> # show updated contents
>>> membuf.buffer
'\000\000\000\000\000\000'
>>>
>>> # any arguments are simply ignored
>>> membuf.zero('XYZ', 123)
>>>
>>> print membuf.zero.__doc__
None = vmsobj__membuf.zero()
Overwrite contents of buffer with NULs.
>>>
Creation:
>>> import pyvms
>>> # create a zero-filled buffer
>>>
>>> membuf = pyvms.vmsobj__membuf (5)
>>> type (membuf)
<type 'vmsobj__membuf'>
>>> membuf
<vmsobj__membuf, buffer at 0x00213f78>
>>> membuf.size
5
>>> membuf.buffer
'\000\000\000\000\000'
>>>
>>> # create a string-filled buffer
>>>
>>> membuf = pyvms.vmsobj__membuf ('data')
>>> type (membuf)
<type 'vmsobj__membuf'>
>>> membuf
<vmsobj__membuf, buffer at 0x00214628>
>>> membuf.size
4
>>> membuf.buffer
'data'
>>>
>>> # invalid attribute access
>>> membuf.bad_attr
Traceback (innermost last):
File "<stdin>", line 1, in ?
AttributeError: non-existing vmsobj__membuf attribute
>>>
>>> membuf.size = 9
Traceback (innermost last):
File "<stdin>", line 1, in ?
AttributeError: non-existing or readonly vmsobj__membuf attribute
>>> membuf.buffer = 'x'
Traceback (innermost last):
File "<stdin>", line 1, in ?
AttributeError: non-existing or readonly vmsobj__membuf attribute
>>> membuf.no_attr = 0
Traceback (innermost last):
File "<stdin>", line 1, in ?
AttributeError: non-existing or readonly vmsobj__membuf attribute
>>>
...
@@