(go to: table of contents, index, list of vms_lib, prev: FID_TO_NAME, next: FIND_FILE_END)
Please note that You MUST check status (and status_value) because
FIND_FILE() does NOT raise an exception when something goes wrong!
Format:
FIND_FILE - Find File
Search for files.
11-NOV-1999 ZE.
status, status_value, context, resultant_filespec = \
vms_lib.find_file (filespec, context, \
[default_filespec], [related_filespec], [flags])
Returns:
Arguments:
Examples:
$! create test area
$ create/directory [.TMP_FF]
$ copy _NLA0: [.TMP_FF]FF_1.TMP
$ copy _NLA0: [.TMP_FF]FF_2.TMP
$ copy _NLA0: [.TMP_FF]FF_3.TMP
$ copy _NLA0: [.TMP_FF]FZ_1.TMP
$ copy _NLA0: [.TMP_FF]FZ_2.TMP
$ copy _NLA0: [.TMP_FF]FZ_2.ZZZ
$ python
[ banner page omitted ]
>>> import vms_lib
>>> import vms_sys
>>> import string
>>> context = 0
>>> status, status_value, context, resultant_filespec = \
... vms_lib.find_file ('[.TMP_FF]FF_*.TMP', context, \
... None, None, 1) # 1=NOWILD
>>>
>>> status, status_value, context, resultant_filespec
(1380650, 0, 2103296, None)
>>> vms_sys.getmsg (status)
('%LIB-E-NOWILD, no wildcard permitted', (0, 0, 0, 0))
>>> print vms_lib.find_file_end (context)
None
>>>
>>> # retry to deallocate an already deallocated context
>>> vms_lib.find_file_end (context)
Traceback (innermost last):
File "<stdin>", line 1, in ?
vms_lib.error: (99596, '%RMS-F-FAB, invalid FAB or FAB not accessible')
>>>
>>> context = 0
>>> status = 1
>>> while (status & 1):
... status, status_value, context, resultant_filespec = \
... vms_lib.find_file ('[.TMP_FF]FF_*.TMP', context, \
... None, None, 0) # 0 = allow wildcards
... status, status_value, context
... if (resultant_filespec != None):
... string.strip (resultant_filespec)
... else:
... vms_sys.getmsg (status)
... vms_sys.getmsg (status_value)
... break # reached end
...
(65537, 0, 2104624)
'DKA100:[PYTHON.PYTHON-1_5_1.VMS.TMP_FF]FF_1.TMP;1'
(65537, 0, 2104624)
'DKA100:[PYTHON.PYTHON-1_5_1.VMS.TMP_FF]FF_2.TMP;1'
(65537, 0, 2104624)
'DKA100:[PYTHON.PYTHON-1_5_1.VMS.TMP_FF]FF_3.TMP;1'
(99018, 2352, 0)
('%RMS-E-NMF, no more files found', (0, 0, 0, 0))
('%SYSTEM-W-NOMOREFILES, no more files', (0, 0, 0, 0))
>>>
>>> # loop completed, context is deallocated
>>> print context
0
>>>
>>> # show a 'success' status value:
>>> vms_sys.getmsg (65537)
('%RMS-S-NORMAL, normal successful completion', (0, 0, 0, 0))
>>> # a status_value of 0 also means no error has accured
>>> context = 0
>>> status, status_value, context, resultant_filespec = \
... vms_lib.find_file ('[.TMP_FF]FF_*.TMP,FZ_*.*', context, \
... None, None, 0) # 0 = no multiple, but wildcards allowed
>>> status, status_value, context
(100052, 0, 2104624)
>>> vms_sys.getmsg (status)
('%RMS-F-SYN, file specification syntax error', (0, 0, 0, 0))
>>>
>>> # WARNING! There is a context left!
>>> print context
2104624
>>> # deallocate it
>>> vms_lib.find_file_end (context)
None
>>>
-- use multiple and provide a default-filespec
$ define FF_LNM FF_*,FZ_* ! logical name search list
>>> context = 0
>>> status = 1
>>> while (status & 1):
... status, status_value, context, resultant_filespec = \
... vms_lib.find_file ('FF_LNM', context, '[.TMP_FF].TMP', \
... None, 2) # 2 = multiple and wildcards allowed
... status, status_value, context
... if (resultant_filespec != None):
... string.strip (resultant_filespec)
... else:
... vms_sys.getmsg (status)
... vms_sys.getmsg (status_value)
... break # reached end
...
(65537, 0, 2104624)
'DKA100:[PYTHON.PYTHON-1_5_1.VMS.TMP_FF]FF_1.TMP;1'
(65537, 0, 2104624)
'DKA100:[PYTHON.PYTHON-1_5_1.VMS.TMP_FF]FF_2.TMP;1'
(65537, 0, 2104624)
'DKA100:[PYTHON.PYTHON-1_5_1.VMS.TMP_FF]FF_3.TMP;1'
(65537, 0, 2104624)
'DKA100:[PYTHON.PYTHON-1_5_1.VMS.TMP_FF]FZ_1.TMP;1'
(65537, 0, 2104624)
'DKA100:[PYTHON.PYTHON-1_5_1.VMS.TMP_FF]FZ_2.TMP;1'
(99018, 2352, 2104624)
('%RMS-E-NMF, no more files found', (0, 0, 0, 0))
('%SYSTEM-W-NOMOREFILES, no more files', (0, 0, 0, 0))
>>>
>>> # a context is still active, because - according to the
>>> # documentation - the data from the previous call is saved
>>> # to be used as the related filespecification on the next
>>> # call
>>> print context
2104624
>>> # deallocate it
>>> vms_lib.find_file_end (context)
>>> import vms_sys
>>> vms_sys.getmsg (status)[0]
'%SYSTEM-S-NORMAL, normal successful completion'
>>>
$! delete test area
$ set PROTECTION=O:RWED [.TMP_FF]*.*;*, []TMP_FF.DIR;*
$ delete [.TMP_FF]*.*;*, []TMP_FF.DIR;*
(go to: table of contents,
index,
list of vms_lib,
prev: FID_TO_NAME,
next: FIND_FILE_END)