(LOGO.JPG) Python for OpenVMS

This example demonstrates the use of RMS datastructures and routines to get the number of keys from a given indexed file. Note that this example has no error checking implemented.

These are system-files to which a non-privileged user does not have access to.


#$% RMS_NUMBER_OF_KEYS.PY
# -----

import pyvms, vms_sys

def key_count (filespec):
  fab = pyvms.vmsobj_fab ()          # create FAB object
  fab.FNA = filespec                 # store filename
  fab.M_SHRPUT = 1                   # allow file sharing

  xabsum = pyvms.vmsobj_xabsum ()    # create SUMmaryXAB object

  fab.XAB = xabsum                   # link XABSUM to FAB

  status = vms_sys.open (fab)        # open file and fill FAB/XAB
  # print status
  # print vms_sys.getmsg (status)

  number_of_keys = xabsum.B_NOK      # count is in XAB$B_NOK

  status = vms_sys.close (fab)       # release file
  # print status
  # print vms_sys.getmsg (status)

  return (filespec,number_of_keys)   # return the data

print key_count ("SYS$SYSTEM:SYSUAF.DAT")
print key_count ("SYS$SYSTEM:VMSMAIL_PROFILE.DATA")

# -----
#%$


Example run:

$ python NUMBER_OF_KEYS.PY
('SYS$SYSTEM:SYSUAF.DAT', 4)
('SYS$SYSTEM:VMSMAIL_PROFILE.DATA', 1)
$


(go to: table of contents, index)

29-OCT-1999 ZE.