(LOGO.JPG) Python for OpenVMS

This example demonstrates use of the SYS$ENTER service from Python. Note that the file identification (FID) and file specification are hard-coded. There is no error checking in the code.


#$% RMS_ENTER.PY
# -----

import pyvms, vms_sys

fab = pyvms.vmsobj_fab()
nam = pyvms.vmsobj_nam()

# file to enter
fab.FNA = "DKA100:[000000]NAME.TYPE;5"

# assign NAM block to FAB block
fab.NAM = nam

# provide a buffer
nam.ESA = pyvms.vmsobj__membuf (255)

status = vms_sys.parse (fab)
print vms_sys.getmsg (status) [0]

# FID of file
nam.W_FID = (1735,9,0)

status = vms_sys.enter (fab)
print vms_sys.getmsg (status) [0]

# -----
#%$


Example run:

$! create a file
$ copy NLA0: ENTER.TMP
$! display its FID
$ directory /FILE_ID ENTER.TMP

Directory USER_HERE:[ZESSIN]

ENTER.TMP;1          (1735,9,0)

Total of 1 file.
$!
$! -- change values in ENTER.PY, here
$!
$ python ENTER.PY
%RMS-S-NORMAL, normal successful completion
%RMS-S-NORMAL, normal successful completion
$!
$! show entered name
$ directory /file_id DKA100:[000000]NAME.TYPE;5
Directory DKA100:[000000]

NAME.TYPE;5          (1735,9,0)

Total of 1 file.
$
-----

$ dump/identifier=(1735,9,0) dka100: /header

Dump of file _$99$DKA100:[USER.ZESSIN]ENTER.TMP;1 on \
 12-MAY-1999 22:45:27.21
File ID (1735,9,0)   End of file block 0 / Allocated 0

                             File Header

Header area
    Identification area offset:           40
[...]


(go to: table of contents, index)

29-OCT-1999 ZE.