When executing iMacros scripts that are being called from a JavaScript file launched via the iMacros interface in FF, the plug-in just jumps to the next step in the JavaScript file when an error occurs within an individual iMacros script it's playing back.
If this script had been launched separately from iMacros then the script would quit at that point and the relevant error message would be displayed in the status window and the script would not continue.
How can I get iMacros to abort playing back the rest of the JavaScript when it encounters an error in an iMacros script it is playing back, instead of just jumping to the next line in the JavaScript file?
How to make iMacros abort when errors occur via JavaScript
Forum rules
iMacros EOL - Attention!
The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely,
The Progress Team
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
iMacros EOL - Attention!
The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.
Thank you again for your business and support.
Sincerely,
The Progress Team
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Re: How to make iMacros abort when errors occur via JavaScri
If anyone's interested, I came up with a solution to this, well, one relevant to my own scripts.
Include the JS function at the top of the script:
After executing each .IIM script make the following call:
And lastly, on the last line for every script you are running include the following:
Include the JS function at the top of the script:
Code: Select all
function checkFail(x,y) {
if (x > 0)
return;
// this message displays only if x is less than 10.
alert ("The script has failed here! ("+y+")");
iimExit();
}
Code: Select all
checkFail(iimGetLastExtract(1),"<PUT THE SCRIPT NAME HERE>");
Code: Select all
SET !EXTRACT 1
Re: How to make iMacros abort when errors occur via JavaScri
This Approach will work if you don't do any EXTRACT(s) in the .iim Scripts, otherwise you need to reset '!EXTRACT' to NULL, I think, just before the "SET !EXTRACT 1" and that complicates things a bit if you were doing Extracts in .iim Scripts and wanted to pass some Values back to the .js Script.Cybes wrote:If anyone's interested, I came up with a solution to this, well, one relevant to my own scripts.
Include the JS function at the top of the script:After executing each .IIM script make the following call:Code: Select all
function checkFail(x,y) { if (x > 0) return; // this message displays only if x is less than 10. alert ("The script has failed here! ("+y+")"); iimExit(); }
And lastly, on the last line for every script you are running include the following:Code: Select all
checkFail(iimGetLastExtract(1),"<PUT THE SCRIPT NAME HERE>");
Code: Select all
SET !EXTRACT 1
It looks to me like you are reinventing the Wheel and it would be simpler to use the Return Code for 'iimPlay()', I would think...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: How to make iMacros abort when errors occur via JavaScri
That's not necessarily true.
As things go the scripts in question mostly perform a SAVEAS EXTRACT towards the end, so this resets EXTRACT back to a null value, so what you're describing is mostly not an issue for me.
For the scripts where I do want to pass values through (and some I do), it's still very simple to do so, I just 'ADD !EXTRACT ...' and merely need to call iimGetLastExtract(2) (or ..3/etc) to grab it's value. This also ensures that the array held within EXTRACT is not populated with other values that are effectively useless to me at that point in time (but may have been valuable during the scripts execution), as the array I have is clean of any other values but exactly what I want (and I do tend to use EXTRACT a fair bit).
So for my scripts, this works well as I have control over the mechanism when it does fall over. The iMacros plug-in interface still displays the error code, so there is no added value in my script having to individually interpret specific return codes, as if it encounters an error I want it to stop, not find a way to continue (as it does by default if you don't explicitly tell it to stop).
If my requirements were different then I could alter my JS function to use iimPlay return codes for the conditional check and the code would be a bit more streamlined, but I came up with my solution before I realised iimPlay had return codes (I may be an expert in the iMacros scripting language but I am in comparably far new territory with using it's JS interface!).
As things go the scripts in question mostly perform a SAVEAS EXTRACT towards the end, so this resets EXTRACT back to a null value, so what you're describing is mostly not an issue for me.
For the scripts where I do want to pass values through (and some I do), it's still very simple to do so, I just 'ADD !EXTRACT ...' and merely need to call iimGetLastExtract(2) (or ..3/etc) to grab it's value. This also ensures that the array held within EXTRACT is not populated with other values that are effectively useless to me at that point in time (but may have been valuable during the scripts execution), as the array I have is clean of any other values but exactly what I want (and I do tend to use EXTRACT a fair bit).
So for my scripts, this works well as I have control over the mechanism when it does fall over. The iMacros plug-in interface still displays the error code, so there is no added value in my script having to individually interpret specific return codes, as if it encounters an error I want it to stop, not find a way to continue (as it does by default if you don't explicitly tell it to stop).
If my requirements were different then I could alter my JS function to use iimPlay return codes for the conditional check and the code would be a bit more streamlined, but I came up with my solution before I realised iimPlay had return codes (I may be an expert in the iMacros scripting language but I am in comparably far new territory with using it's JS interface!).