michael evans wrote: > Hello all > > I need some help with some logic... > > I am watching a source folder for incoming folders of jpeg files. > > The arriving folders of jpeg files can be coming from a remote sender via > FTP or from a local sender via a file system transfer. The arriving folders > of jpeg files are then copied to various output folders based on metadata > contained in the first jpeg file found in the arriving folder. > > In order to avoid I/O errors, I total the size of all jpegs file in an > arriving folder, wait 30 seconds, and again total the size of all jpeg > files. If the two totals are the same then I proceed to copy the folder of > jpeg files to the various output folders. > > At the end of the copy process the source folder of jpegs is placed in a > dated 'Done' folder or in an 'Error' > > > Anyhow the fn below is what I have come up with: > > clear local > local fn ageTheFolder(aaFldrPath$, delaySecs&) > dim @ FldrBytesOld as long, FldrBytesNew as long > dim @ timeStart as long, timeNew as long > dim @ ok as int, failTries as int > > FldrBytesNew = fn getSizeOfJPEGsinFldr(aafldrPath$) > > while (FldrBytesNew <> FldrBytesOld) and (failTries < 5) > inc(failTries) > long if failTries < 5 > FldrBytesOld = FldrBytesNew > delay delaySecs& * _sec > FldrBytesNew = fn getSizeOfJPEGsinFldr(aafldrPath$) > xelse > exit wend > end if > wend > > long if (failTries < 5) and (FldrBytesNew = FldrBytesOld) > ok = _true > xelse > ok = _false > end if > 'GETDATETIME( t& ) > > end fn = ok > > > Uses DELAY which seems very inelegant. > > > Is there a better way to accomplish the same thing? > Perhaps you could use a threaded function with a long delay between calls. Alain