Macro Sheduler bug

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
rblack
Pro Scripter
Posts: 87
Joined: Sat Dec 22, 2007 12:39 pm

Macro Sheduler bug

Post by rblack » Fri Sep 17, 2010 8:39 am

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

rblack
Pro Scripter
Posts: 87
Joined: Sat Dec 22, 2007 12:39 pm

Post by rblack » Fri Sep 17, 2010 8:49 am

i found a solution - you need to add a single line of commented code after the "until" function, so the end looks like this:

Until>k,file_names_count
//
EndIF

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Sep 17, 2010 9:07 am

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?

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Fri Sep 17, 2010 9:15 am

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?

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts