DSWaitForFile

Use the DSWaitForFile function to suspend a job until a named file either exists or does not exist.

Syntax


Reply = DSWaitForFile(Parameters)

Parameters is the full path of file to wait on. No check is made as to whether this is a reasonable path (for example, whether all directories in the path exist). A path name starting with "-", indicates a flag to check the nonexistence of the path. It is not part of the path name.

Parameters might also end in the form " timeout:NNNN" (or "timeout=NNNN") This indicates a non-default time to wait before giving up. There are several possible formats, case-insensitive:

  • nnn number of seconds to wait (from now)
  • nnnS ditto
  • nnnM number of minutes to wait (from now)
  • nnnH number of hours to wait (from now)
  • nn:nn:nn wait until this time in 24HH:NN:SS. If this or nn:nn time has passed, will wait till next day.

The default timeout is the same as "12H".

The format might optionally terminate "/nn", indicating a poll delay time in seconds. If omitted, a default poll time is used.

Reply might be:

  • DSJE.NOERROR (0) OK - file now exists or does not exist, depending on flag.
  • DSJE.BADTIME Unrecognized Timeout format
  • DSJE.NOFILEPATH File path missing
  • DSJE.TIMEOUT Waited too long

Examples


Reply = DSWaitForFile("C:\ftp\incoming.txt timeout:2H")

(wait 7200 seconds for file on C: to exist before it gives up.)


Reply = DSWaitForFile("-incoming.txt timeout=15:00")

(wait until 3 p.m. for file in local directory to NOT exist.)


Reply = DSWaitForFile("incoming.txt timeout:3600/60")

(wait 1 hour for a local file to exist, looking once a minute.)