Hello to everyone, I'm currently having a problem with my code.
I'm currently using iMacros build 844 on Google Chrome and on Windows 10 in french.
Let me explain you. My goal is to take a part of the URL and to change juste a number into it, adding it 1.
Here is my code :
VERSION BUILD=844 RECORDER=CR
SET !TIMEOUT_PAGE 15
SET !ERRORIGNORE YES
SET !EXTRACT_TEST_POPUP NO
SET !VAR1 {{!URLCURRENT}}
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\";
function incremente(expression){
var expression1 = "";
expression1 = expression.match(/\d{1,}/);
expression1 = expression1 + 1;
expression1 = '&page' + expression1 + '&';
return expression1;}
s.replace(/&page=\d{1,}&/, incremente(/&page=\d{1,}&/));")
PROMPT {{!VAR1}}
PROMPT {{!VAR2}}
And this does not work telling me : SyntaxError: wrong format of SET command...
Is it possible to declare a function directly into an EVAL() in iMacros? I've been looking for some answers on the web and it's a bit difficult to find.
If someone could help me, it would be nice! Best regards.
Function into EVAL() ?
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: Function into EVAL() ?
Hello,
Why not?dance4me wrote:Is it possible to declare a function directly into an EVAL() in iMacros?
Code: Select all
SET !EXTRACT someStuff&page=100&someStuffAgain
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; function incremente(expression){var expression1 = parseInt((\"\" + expression).match(/\\d{1,}/)) + 1; expression1 = '&page=' + expression1 + '&'; return expression1;} s.replace(/&page=\\d{1,}&/, incremente(s.match(/&page=\\d{1,}&/)));")
PROMPT {{!EXTRACT}}
PROMPT {{!VAR2}}
Re: Function into EVAL() ?
Thank you very much for sharing your knowledge!
Question :
May I ask why you use : parseInt((\"\" + expression).match(/\\d{1,}/))
instead of parseInt(expression.match(/\\d{1,}/)) ?
Remark :
You wrote : s.replace(/&page=\\d{1,}&/, incremente(s.match(/&page=\\d{1,}&/)));")
I would think there is no need to \\ in the match parenthesis since s.match is waiting for a regex. Don't you think so?
Thanks again and have a good day
Question :
May I ask why you use : parseInt((\"\" + expression).match(/\\d{1,}/))
instead of parseInt(expression.match(/\\d{1,}/)) ?
Remark :
You wrote : s.replace(/&page=\\d{1,}&/, incremente(s.match(/&page=\\d{1,}&/)));")
I would think there is no need to \\ in the match parenthesis since s.match is waiting for a regex. Don't you think so?
Thanks again and have a good day
Re: Function into EVAL() ?
Just feel free to edit the macro as you'd like.dance4me wrote:Don't you think so?