hi, i have the following code to delete all older bmp files than 7 days,
//==========
GetFileList>C:\*.bmp,files
Separate>files,;,file_names
if>FILE_NAMES_COUNT>0
Let>k=0
Repeat>k
Let>k=k+1
IfFileChanged>file_names_%k%,>7
//delete the file
//MessageModal>file_names_%k%
DeleteFile>file_names_%k%
EndIf
Until>k,file_names_count
EndIf
//=============
but there is a bug in Macro Sheduler 11 which i own - when there are no older files, and FILE_NAMES_COUNT=0, on the if> condition it goes to the line Until> and then to Repeat, and it makes an everlasting loop.
It should go to the last line of code - EndIf
Macro Sheduler bug
Moderators: JRL, Dorian (MJT support)
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
This is a bug with IfFileChanged, incorrectly causing the outer If to jump to the IfFileChanged's EndIf statement. The bug is not present in v12.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
The bug in v11 is only when using IfFileChanged with else/endif. If using labels it works fine. So the correct workaround is as follows:
Code: Select all
//==========
GetFileList>C:\*.bmp,files
Separate>files,;,file_names
if>FILE_NAMES_COUNT>0
Let>k=0
Repeat>k
Let>k=k+1
IfFileChanged>file_names_%k%,>7,lbFCTrue,lbFCFalse
Label>lbFCTrue
//delete the file
//MessageModal>file_names_%k%
DeleteFile>file_names_%k%
Label>lbFCFalse
Until>k,file_names_count
EndIf
//=============
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?