Implementing true "file watch".
Dim file_size, number
Dim too_small, boolean
Dim wait_time, number
Dim timeout, boolean
CHECK_FILE_SIZE:
FileSize "myfile.txt", file_size
// check is file size is less than 1Mb ( 1048576 bytes )
isLess file_size, 1048576, too_small
IfThen too_small, TRY_LATER
// check if we are waiting already too long (more than 10
minutes)
isGreater wait_time, 600, timeout
IfThen timeout, TIMEOUT
// Notify system admin.
MailSend "Exchange
Settings", "pass", "sysadmin@mycompany.com", &
"File watch job failed", "Giving up while waiting for myfile.txt"
exit
TIMEOUT:
// wait 30 seconds then try again
Wait 30
Add wait_time, 30, wait_time
GoTo CHECK_FILE_SIZE
TRY_LATER:
// OK, file size is above average, wait extra 10 seconds then try again
Wait 10
// ...
// perform main operation here
// ...
Example 2:
Dim file_handle, number
Dim wait_time, number
Dim timeout, boolean
FileOpen "myfile.txt", "StreamMode", "Read", True,
file_handle
LoopUntil file_handle, END_LOOP
// check if we are waiting already too long (more than 10
minutes)
isGreater wait_time, 600, timeout
IfThen timeout, TIMEOUT
// Notify system admin.
MailSend "Exchange
Settings", "pass", "sysadmin@mycompany.com", &
"File watch job failed", "Giving up while waiting for myfile.txt"
exit
TIMEOUT:
// wait 30 seconds then try again
Wait 30
Add wait_time, 30, wait_time
// try opening file
FileOpen "myfile.txt", "StreamMode",
"Read", True, file_handle
END_LOOP:
// Release file
FileClose file_handle
// ...
// perform main operation here
// ...