Sys(2000)

This is a nice little function that's been mostly superseded by later additions to the language. It returns the name of a file matching a skeleton. You can use it in a loop to find all files that match a given skeleton.

Usage

cFileName = SYS( 2000, cSkeleton [ ,1 ] )

Parameter

Value

Meaning

cSkeleton

Character

A file specification. It can contain the DOS wildcards "?" and "*".

1

Included

Find the next matching file.

Omitted

Find the first matching file.


The order in which filenames are returned is the order they appear in a DOS DIR listing. Of course, this is a pretty useless order. ADIR(), which is generally a better choice than SYS(2000), also uses the DOS order, but you can then ASORT() to get some useful order. The only situation where we've found a use for the SYS(2000) function is one where we are polling a directory for the next file matching a skeleton, grabbing it for processing, and immediately deleting or renaming it. Multiple machines can poll the same directory, and each will get the name of the next file in queue. Grabbing the first available name is faster than searching an entire directory listing, particularly on slower hardware.

Example

* Our own version of ADIR() - no reason to use it
* Assume cSkel is the file skeleton
LOCAL nFileCount, cFileName, aFiles[1]
 
cFileName=SYS(2000,cSkel)
nFileCount=0
DO WHILE NOT EMPTY(cFileName)
   nFileCount = nFileCount + 1
   DIMENSION aFiles[nFileCount]
   aFiles[nFileCount] = cFileName
   cFileName = SYS(2000,cSkel,1)
ENDDO

See Also

ADir(), Directory, Display Files, List Files


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .