Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Proclip2 Library - <b> sdir() </b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 SDIR() 

          Similar to the standard Clipper ADIR command, the SDIR command
          provides the programmer with the ability to read any valid
          directory and obtain standard directory information on an entry by
          entry basis.  Entries include all valid directory entries including
          subdirectory and volume label names.  Using the attribute filter,
          the SDIR function will only return those files matching the
          attributes.  SDIR will return the entry name, date, time or file
          size depending upon the function call used.


      Format: 

               <memvar> = SDIR(pattern, 'first' [,fileattr])
               <memvar> = SDIR('next')
               <memvar> = SDIR('date')
               <memvar> = SDIR('time')
               <memvar> = SDIR('size')
               <memvar> = SDIR(pattern, 'count' [,fileattr])


      Parameters: 

               pattern...Character string variable or constant, non case
                         sensitive, which informs the function of the entry
                         pattern to search with.  The PATTERN may contain any
                         valid drive or DOS path as well as wildcards (eg.
                         "*" & "?").

               'first'...Character string variable or constant, non case
                         sensitive, which instructs the function to obtain
                         the first matching directory entry in the specified
                         directory.  If FIRST is specified then a PATTERN
                         must be supplied.  FIRST reinitializes the search
                         function and sets up the function for subsequent
                         activity based on the PATTERN provided.

               'next'....Character string variable or constant, non case
                         sensitive, which instructs the function to obtain
                         the next matching entry based on the last FIRST
                         function.  In other words, a FIRST must be called
                         first in order to obtain the first entry and
                         initialize the function.  Subsequent NEXT functions
                         will continue reading the directory one entry at a
                         time until all entries have been read.

               'date'....Character string variable or constant, non case
                         sensitive, which instructs the function to obtain
                         the date of the last entry returned with either
                         FIRST or NEXT, whichever was last.  If the file is
                         currently open (as in an active database file) this
                         date may not reflect the actual last update date.
                         In these cases the active file should be closed to
                         allow the operating system to update the directory
                         prior to requesting this function.

               'time'....Character string variable or constant, non case
                         sensitive, which instructs the function to obtain
                         the time of the last entry returned with either
                         FIRST or NEXT, whichever was last.  As in DATE the
                         file should be closed prior to requesting this
                         function.

               'size'....Character string variable or constant, non case
                         sensitive, which instructs the function to obtain
                         the size of the last entry returned with either
                         FIRST or NEXT, whichever was last.  As in TIME and
                         DATE above the file should be closed prior to
                         requesting this function.

               'count'...Character string variable or constant, non case
                         sensitive, which instructs the function to obtain
                         the number of files matching PATTERN.  If COUNT is
                         specified then PATTERN must also be specified.

               fileattr..Character string variable or constant, non case
                         sensitive, which instructs the function to only
                         select those directory entries which have at least
                         these attributes.

                                  (valid file attributes)

                              r/o                 Read only
                              hid                 Hidden
                              sys                 System
                              vol                 Volume label
                              sub                 Subdirectory
                              arc                 Archive


      Examples: 

               1.   Read the current directory and when the chosen file is
                    found obtain the date, time and size of the file.  As no
                    attribute is specified all directory entries will be
                    returned which match the pattern and have at least the
                    archive attribute set (arc).

                    .
                    .
                    .
                    pattern = 'YOUR????.DBF'
                    filename = sdir(pattern,'first')
                    if .not. empty(filename)
                         filedate = sdir('date')
                         filetime = sdir('time')
                         filesize = sdir('size')
                    endif
                    .
                    .
                    .

               1.   Read a different, valid, directory and return all of the
                    names of all subdirectory entries by specifying an
                    attribute of subdirectory only.

                    .
                    .
                    .
                    aSubDir = sdir('C:\LEVEL1\LEVEL2\*.*','first','sub')
                    do while .not. empty(aSubDir)
                         ? direntry
                         aSubDir = sdir('next')
                    enddo
                    .
                    .
                    .


      Returns: 

               'first'...If successful, <memvar> is set to a character string
                         type and returned with the filename of the first
                         file matching PATTERN.  If unsuccessful, <memvar> is
                         set to a character string type and returned with a
                         zero length (null).

               'next'....Same as FIRST.

               'date'....If successful, <memvar> is set to a date type and
                         returned with the entry date per the active
                         directory entry.  If unsuccessful, <memvar> is set
                         to a date type and returned with a '00/00/00' date.

               'time'....If successful, <memvar> is set to a character type
                         and returned with the entry time per the active
                         directory entry in HH:MM:SS format.  If
                         unsuccessful, <memvar> is set to a character type
                         and returned with a zero length (null).

               'size'....If successful, <memvar> is set to a numeric type and
                         returned with the file size (subdirectory entries
                         are always zero (0) length) per the active directory
                         entry.  If unsuccessful, <memvar> is set to a
                         numeric type and returned with a zero value (0).

               'count'...If successful, <memvar> is set to a numeric type and
                         returned with the number of entries matching the
                         specified pattern.  If unsuccessful, <memvar> is set
                         to a numeric type and returned with a zero value
                         (0).


      Cautions: 

               None.

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson