PDS DIRECTORY

Returns member names from a PDS directory.

Type

PDS function

Format

PDS(DIRECTORY handle)
handle
The handle established by SETWRT for a member name of *DIR*.

Usage Notes®

  1. PDS DIRECTORY returns a string that contains the concatenation numbers and member names in the following format:
    nnncccccccc,nnncccccccc,nnncccccccc,...,nnncccccccc 

    where nnn is the zero-based concatenation number and cccccccc is the member name. A null string indicates end-of-directory.

  2. The programmer is responsible for dealing with duplicate member names with different concatenation numbers.
  3. Use PDS SETWRT with a member name of *DIR* to obtain the handle for PDS DIRECTORY. This serializes the PDS so that the directory cannot be updated while it is being read.
  4. Issue PDS DIRECTORY function calls until the processor returns a null string.
  5. Each time PDS DIRECTORY is issued, the processor returns 84 member names unless there are less than 84 member names left to read.
  6. After you have retrieved the last directory entries, issue a PDS 'END' so the directory is released.

Example

This example requests a handle to the directory for PDS MY.TEST.PDS, retrieves member names, and lists the names.

set DHand (pds(setwrt '*DIR*' '*MY.TEST.PDS'))
if &DHand > 0 do
  while (set MList (pds(directory &DHand))) do
    while '&MList' do
      log('Member name: &substr('&MList' 3 8)' 0 1 1)
      set MList '&substr('&MList' 12)'
    end
  end
  pds('end' &DHand)
end

See Also

PDS 'END'

PDS SETWRT