Creating "retry on fail" jobs (self-rescheduling jobs)

// Normally this job  runs daily at 11:30. It executes several database stored procedures after
// all required files arrived and successfully loaded into database. However, if some files "failed"
// to arrive on time,  this jobs reschedules itself to repeat file check again in 30 minutes. When
// all required files exist, it restores original schedule and calls another job that actually
// loads files and executes stored procedures.

Dim found, boolean

// ... check for files
        FileExists( "k:\network\data\account.dat", found )
        if( found, CHECK_HOLDINGS, RETRY_LATER )
        FileExists( "k:\network\data\holding.dat", found )
        if( found, CHECK_TRADES, RETRY_LATER )
        FileExists( "k:\network\data\trade.dat", found )
        if( found, START_DB_LOAD, RETRY_LATER )
        JobRun( "Daily Database Load" )
        Dim today, date
        Dim tomorrow, date
        Dim start_time, datetime
        Today( today )
        DateAdd( today, 1, tomorrow )
        DateTime( tomorrow, 11:30,  start_time )
        JobModify( "File Watcher", "START_TIME",  start_time )
        // all done

        Dim today, date
        Dim system_time, time
        Dim start_time, datetime
        Today( today )
        Now( system_time)
        DateTime( today, system_time,  start_time )
        DateTimeAdd( start_time, 1800, start_time )
        JobModify( "File Watcher", "START_TIME",  start_time )