Search code examples
imacros

Save last {{!loop}} value in iMacro script after error


I am running an iMacro script in the free FF Extension format.

This Macro runs all night in a loop and uses the {{!LOOP}} variable. During the night the script might crash and when it does I need a way to see at whatvalue of {{!LOOP}} the script crashed in order to pick off at that part.

How can I save the last {{!loop}} value in iMacro script even after an error?


Solution

  • I use the following code to update the url on the next tab to be !LOOP so when it crashes the value there is exactly what you need. You need the 2nd tab to already be open. This method is very quick!

    TAB T=1
    'your code goes here
    
    'don't wanna wait long
    SET !TIMEOUT_PAGE 1 
    'don't crash because http://1 doesn't exist
    SET !ERRORIGNORE YES 
    'go to next tab - notice this tab has to already be open
    TAB T=2  
    'update url in tab
    URL GOTO={{!LOOP}}  
    'return to original tab
    TAB T=1  
    'timeout back to normal
    SET !TIMEOUT_PAGE 60  
    'continue failing on error like in default
    SET !ERRORIGNORE NO 
    

    You can also save to disk for more reliability and tracking of individual loops that failed if you want to continue even when failing.