NUMBER_OF_KEYS.TXT                                       5-JUN-1999 ZE.

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

# -----
# NUMBER_OF_KEYS.PY

import pyvms, vms_sys

def key_count (filespec):
  fab = pyvms.vmsobj_fab ()          # create FAB object
  fab.FNA = filespec                 # put 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 KEYCOUNT.PY
('SYS$SYSTEM:SYSUAF.DAT', 4)
('SYS$SYSTEM:VMSMAIL_PROFILE.DATA', 1)
$
