LOOP in my Macro

Discussions and Tech Support specific to the iMacros for Chrome extension.
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
Post Reply
Torsten156
Posts: 15
Joined: Wed Jul 08, 2020 6:18 am

LOOP in my Macro

Post by Torsten156 » Wed Jul 22, 2020 12:49 pm

Hi,
i need a solution for running code several times in my Script. In C++ i use the for...loop. What can i use in iMacro? I mean LOOP?
Here an example with 5 steps in pseudocode:

Code: Select all

Step = 1
Start
	...do something
	...Step = Step + 1
got to Start when Step <=5 else Stop
I hope u understand me ;-)

Regards
Torsten


Here my Config:
iMacros - 10.0.5
Chrome - 80.0.3987.122
OS - WIN 10 Enterprise
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: LOOP in my Macro

Post by chivracq » Wed Jul 22, 2020 2:46 pm

Torsten156 wrote:
Wed Jul 22, 2020 12:49 pm
Hi,
i need a solution for running code several times in my Script. In C++ i use the for...loop. What can i use in iMacro? I mean LOOP?
Here an example with 5 steps in pseudocode:

Code: Select all

Step = 1
Start
	...do something
	...Step = Step + 1
got to Start when Step <=5 else Stop
I hope u understand me ;-)

Regards
Torsten


Here my Config:

Code: Select all

iMacros - 10.0.5
Chrome - 80.0.3987.122
OS - WIN 10 Enterprise

Hum, pay Attention to select the "correct" Sub-Forum when you open a Thread, (or I don't try to help...), this one has nothing really specific to the 'iMacros for CR' Sub-Forum and will probably get moved to the 'General' Sub-Forum..., or maybe to the 'Scripting Interface' Sub-Forum by the Forum Admin... :!:

You mention your FCI, perfect, but 'Free'/'PE' is still missing...?
And hum..., are you "sure" you are (still) on CR80...? :o
Preventing CR from updating itself is really "a pain in the ass" and if running Win10_ENT, I would be "surprised" if your IT-Dept prevents CR from updating and keeps that Browser 3 or 4 Versions behind, missing many Security Fixes... :o

>>>

But tja..., Looping Functionality in iMacros is achieved using the Built-in '!LOOP' Mechanism and the 'Play (Loop)' Button from the iMacros Side-Panel. 8)

For "Advanced"/"Complex" Conditional Logic, you would need the 'Scripting Interface' ('SI') from the iMacros Enterprise Edition (where you could then even use your "trusted" C++ Prog-Language 8) ) with any of the 4 Browsers supported by iMacros, ... or only available on FF with iMacros for FF v8.9.7 (not supported in v10.0.2 for FF), you could use a '.js' Script (instead of an '.iim' Script) where you can use the "Full Power" of JavaScript + all iMacros Commands from the 'SI'... But you'll then need to implement yourself your whole Looping Mechanism/Logic... :idea:
And concerning v8.9.7 for FF, this Version only works until FF55/56, or on Browsers forked on FF that didn't adopt the WebExtensions Architecture, like 'Pale Moon' v28, 'Basilisk' v2020, 'WaterFox' v2020...

But all Conditional Logic/Behaviour, with Partial/Nested Looping can also be implemented in "pure" '.iim' with a few "Tricks" and Techniques, but it all depends on the exact Content and Functionality/Actions that you want in all your "Steps [1-5]" and your "do something"... Your current Description/Scenario is a bit "vague", you would need to give more Details...
- (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...
Torsten156
Posts: 15
Joined: Wed Jul 08, 2020 6:18 am

Re: LOOP in my Macro

Post by Torsten156 » Wed Jul 22, 2020 3:32 pm

Hi chivracq,

thanks for this answer. I would like to use "pure" iim-Code. :roll: Can you tell me a "Trick" for my problem? Here my Code:

Code: Select all

VERSION BUILD=1005 RECORDER=CR
URL GOTO=https://xxxxx.xxxxx.com/
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:# ATTR=ID:username CONTENT=V4909
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ACTION:# ATTR=NAME:password CONTENT=xxxxx
TAG POS=1 TYPE=SPAN ATTR=ID:dijit_form_Button_4_label
WAIT SECONDS=7
TAG POS=1 TYPE=DIV ATTR=ID:dijit_layout_ContentPane_0
TAG POS=1 TYPE=TD ATTR=ID:dijit_MenuItem_7_text
WAIT SECONDS=2



SET !VAR2 16
SET !VAR1 1

==> START the LOOP

TAG POS={{!VAR1}} TYPE=I ATTR=CLASS:fa<SP>fa-table<SP>optionsIcon
WAIT SECONDS=2
TAG POS=3 TYPE=SPAN ATTR=CLASS:dijitReset<SP>dijitInline<SP>dijitArrowButtonInner
TAG POS=1 TYPE=TD ATTR=ID:dijit_MenuItem_{{!VAR2}}_text
TAG POS=1 TYPE=I ATTR=CLASS:action-icon<SP>fa<SP>fa-compress&&DATA-DOJO-ATTACH-POINT:iconNode

ADD !VAR1 1
ADD !VAR2 13
==> END LOOP 
The !VAR1 is an increment of 1 with a Startvalue of 1. The !VAR2 is an increment of 13 with a Startvalue of 16.
The part of the LOOP is between "START the LOOP" and "END LOOP". This LOOP should run through 60 times.

I hope this information is good/enough...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: LOOP in my Macro

Post by chivracq » Wed Jul 22, 2020 3:53 pm

Torsten156 wrote:
Wed Jul 22, 2020 3:32 pm
Hi chivracq,

thanks for this answer. I would like to use "pure" iim-Code. :roll: Can you tell me a "Trick" for my problem? Here my Code:

Code: Select all

VERSION BUILD=1005 RECORDER=CR
URL GOTO=https://xxxxx.xxxxx.com/
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:# ATTR=ID:username CONTENT=V4909
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ACTION:# ATTR=NAME:password CONTENT=xxxxx
TAG POS=1 TYPE=SPAN ATTR=ID:dijit_form_Button_4_label
WAIT SECONDS=7
TAG POS=1 TYPE=DIV ATTR=ID:dijit_layout_ContentPane_0
TAG POS=1 TYPE=TD ATTR=ID:dijit_MenuItem_7_text
WAIT SECONDS=2

SET !VAR2 16
SET !VAR1 1

==> START the LOOP

TAG POS={{!VAR1}} TYPE=I ATTR=CLASS:fa<SP>fa-table<SP>optionsIcon
WAIT SECONDS=2
TAG POS=3 TYPE=SPAN ATTR=CLASS:dijitReset<SP>dijitInline<SP>dijitArrowButtonInner
TAG POS=1 TYPE=TD ATTR=ID:dijit_MenuItem_{{!VAR2}}_text
TAG POS=1 TYPE=I ATTR=CLASS:action-icon<SP>fa<SP>fa-compress&&DATA-DOJO-ATTACH-POINT:iconNode

ADD !VAR1 1
ADD !VAR2 13
==> END LOOP 
The !VAR1 is an increment of 1 with a Startvalue of 1. The !VAR2 is an increment of 13 with a Startvalue of 16.
The part of the LOOP is between "START the LOOP" and "END LOOP". This LOOP should run through 60 times.

I hope this information is good/enough...

Yeah, but "FCIM" (again..., + read my Sig) for me to read/follow up/do any Thinking, I asked you to mention if you are using the 'Free' or 'PE' Version of iMacros for CR v10.0.5, ... and to "confirm"/check that you are "really" using CR80, don't ignore my Qt's... :(
=> Edit your FCI in your OP to include that (missing) Info...
- (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...
Torsten156
Posts: 15
Joined: Wed Jul 08, 2020 6:18 am

Re: LOOP in my Macro

Post by Torsten156 » Thu Jul 23, 2020 6:46 am

So, my Profile is complete ;-)
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: LOOP in my Macro

Post by chivracq » Thu Jul 23, 2020 8:00 am

Torsten156 wrote:
Thu Jul 23, 2020 6:46 am
So, my Profile is complete ;-)

Code: Select all

- iMacro for Chrome (Free Edition) 10.0.5
- Chrome Version 80.0.3987.122 (Offizieller Build) (64-Bit)
- WIN 10 Enterprise

OK, so v10.0.5 for CR 'Free' and you are indeed on CR80...
(And correct Spelling is "iMacros" btw...)

But hum, good Intention but placing your FCI in your Sig is not a "good Idea" and it is rather confusing actually because you only have one Dynamic Sig for the whole Forum, so you still need to hard-code your FCI in your OP when you open a Thread... And Sigs are not visible when posting a Reply...
You would speed up the "Process" if you took 1 Min to read the Forum Rules... :idea:

>>>

Then OK, for the 2 Inner Loops you will need to compute those 2 Loops based on the '!LOOP' Var:
- '!VAR1' starting at 0 and '!VAR1' + '!LOOP' using the 'ADD' Command.
- '!VAR2' starting at 3 and '!VAR2' + 13 x '!LOOP' using the 'EVAL()' Command. (Or you can use 13 times the 'ADD' Command if you prefer, but 'EVAL()' only takes 1 Line of Code and as you are using the 'Free' Version, you can only put 50 Lines in your Script...)

For the Login Section that you want to execute only on '!LOOP'=1, if the URL in the 'URL GOTO' Command is a Login Page then you'll need to use a "Conditional 'URL GOTO'", or also if that URL is your "Destination" Page and the Login Page only appears if you got logged out, but you don't want to reload that Page on every Loop.
The Fields to enter the Login + Password + click on the Submit Button are probably not present anymore on the Page for '!LOOP'>1, then you use '!ERRORIGNORE' + a short '!TIMEOUT_STEP' (=0) to bypass those Lines. The '!TIMEOUT_STEP' Value can also be made Conditional if you want...

For the 2 'TAG' Statements on the 2 'DIV' Elements, see if the same Method can be applied to those 2 Elements if they are not present on the Page or if those 2 Statements don't do anything from '!LOOP'=2, or you'll need to compute a "1"/"0" with 'EVAL()' to use for "POS=n", "POS=0" won't do anything.

And you'll also need a "Conditional 'WAIT'" for the 2 'WAIT' Statements if you don't want the Script to wait for 7+2 Sec on every Loop.

And for all "Conditional + stg" Parts that I mentioned, you'll find relevant Threads with Code Examples if you search the Forum using those Terms as Search Keywords... 8)
- (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...
Torsten156
Posts: 15
Joined: Wed Jul 08, 2020 6:18 am

Re: LOOP in my Macro

Post by Torsten156 » Mon Jul 27, 2020 8:25 am

Hi,
i changed my Script and now it works fine! Thank's.
Now i have a question. Currently i start the script via command line (start Chrome and open my WebPage with the bookmark). For one time works. How can i start the script via commandline with the Loop-Function (25x)??? Is this possible?

thanks...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: LOOP in my Macro

Post by chivracq » Mon Jul 27, 2020 1:08 pm

Torsten156 wrote:
Mon Jul 27, 2020 8:25 am
Hi,
i changed my Script and now it works fine! Thank's.
Now i have a question. Currently i start the script via command line (start Chrome and open my WebPage with the bookmark). For one time works. How can i start the script via commandline with the Loop-Function (25x)??? Is this possible?

thanks...

Alright, nice to hear, but hum..., would be "nice" if you shared/posted your Final Script, to finish this Thread a bit neatly and to make it also useful for other Users... And I would probably be able to improve/tune it a bit...

>>>

Then concerning your "next Qt", well, finish first this one "neatly" and useful for the Community, and open a (separate) New Thread (in the 'Command Line' Sub-Forum), but I think that's already exactly what your first Thread was about, then there is no Need to open a Duplicate, I had seen it, but I didn't react because "stg" was missing from your FCI or you had not posted any Script, I don't remember... (And I have a very bad Internet Connection at the moment, I cannot check it now...)
So add the missing/extra Info to that Thread and bump it, or open a New Thread if it's a different Qt, (with FCI mentioned and all Info, and FCI hard-coded in your OP, I've told you that your Sig is not the "best Place" to mention your FCI...), and I'll have a Look...
- (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...
Torsten156
Posts: 15
Joined: Wed Jul 08, 2020 6:18 am

Re: LOOP in my Macro

Post by Torsten156 » Tue Jul 28, 2020 7:23 am

Hi,

here my Code. It works well ;-)

Code: Select all

VERSION BUILD=1005 RECORDER=CR
SET !TIMEOUT_STEP 1
SET !ERRORIGNORE YES
URL GOTO=https://xxxx.xxxx.xxx
TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:# ATTR=ID:username CONTENT=MYUSERNAME
SET !ENCRYPTION NO
TAG POS=1 TYPE=INPUT:PASSWORD FORM=ACTION:# ATTR=NAME:password CONTENT=MYPASSWORD
TAG POS=1 TYPE=SPAN ATTR=ID:dijit_form_Button_4_label
WAIT SECONDS=7
TAG POS=1 TYPE=DIV ATTR=ID:dijit_layout_ContentPane_0
TAG POS=1 TYPE=TD ATTR=ID:dijit_MenuItem_7_text
WAIT SECONDS=2

SET !VAR1 0

ADD !VAR1 {{!LOOP}}
TAG POS={{!VAR1}} TYPE=I ATTR=CLASS:fa<SP>fa-table<SP>optionsIcon
WAIT SECONDS=2
TAG POS=3 TYPE=SPAN ATTR=CLASS:dijitReset<SP>dijitInline<SP>dijitArrowButtonInner
TAG POS=1 TYPE=TD ATTR=ID:dijit_MenuItem_16_text
TAG POS=1 TYPE=I ATTR=CLASS:action-icon<SP>fa<SP>fa-compress&&DATA-DOJO-ATTACH-POINT:iconNode
Post Reply