Code simplification - class values increase by one

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
Forum rules
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
Brendo
Posts: 4
Joined: Thu Nov 29, 2018 7:29 pm

Code simplification - class values increase by one

Post by Brendo » Fri Jan 11, 2019 2:14 pm

Hello!

In my code there are numeric values of classes in order of magnification.
Is there a way to simplify the code so as not to copy strings thousands of times?

Example:

Code: Select all

'some code...
TAG POS=1 TYPE=TD ATTR=CLASS:row_1_2 EXTRACT=TXT  
SET !CLIPBOARD {{!EXTRACT}}
'some code...
TAG POS=1 TYPE=TD ATTR=CLASS:row_1_3 EXTRACT=TXT  
SET !CLIPBOARD {{!EXTRACT}}
'some code...
TAG POS=1 TYPE=TD ATTR=CLASS:row_2_2 EXTRACT=TXT  
SET !CLIPBOARD {{!EXTRACT}}
'some code...
TAG POS=1 TYPE=TD ATTR=CLASS:row_2_3 EXTRACT=TXT  
SET !CLIPBOARD {{!EXTRACT}}
'some code...
TAG POS=1 TYPE=TD ATTR=CLASS:row_3_2 EXTRACT=TXT  
SET !CLIPBOARD {{!EXTRACT}}
'some code...
TAG POS=1 TYPE=TD ATTR=CLASS:row_3_3 EXTRACT=TXT  
SET !CLIPBOARD {{!EXTRACT}}
'etc...
chivracq
Posts: 8323
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Code simplification - class values increase by one

Post by chivracq » Mon Jan 14, 2019 11:42 am

Brendo wrote:
Fri Jan 11, 2019 2:14 pm
Hello!

In my code there are numeric values of classes in order of magnification.
Is there a way to simplify the code so as not to copy strings thousands of times?

Example:

Code: Select all

'some code...
TAG POS=1 TYPE=TD ATTR=CLASS:row_1_2 EXTRACT=TXT  
SET !CLIPBOARD {{!EXTRACT}}
'some code...
TAG POS=1 TYPE=TD ATTR=CLASS:row_1_3 EXTRACT=TXT  
SET !CLIPBOARD {{!EXTRACT}}
'some code...
TAG POS=1 TYPE=TD ATTR=CLASS:row_2_2 EXTRACT=TXT  
SET !CLIPBOARD {{!EXTRACT}}
'some code...
TAG POS=1 TYPE=TD ATTR=CLASS:row_2_3 EXTRACT=TXT  
SET !CLIPBOARD {{!EXTRACT}}
'some code...
TAG POS=1 TYPE=TD ATTR=CLASS:row_3_2 EXTRACT=TXT  
SET !CLIPBOARD {{!EXTRACT}}
'some code...
TAG POS=1 TYPE=TD ATTR=CLASS:row_3_3 EXTRACT=TXT  
SET !CLIPBOARD {{!EXTRACT}}
'etc...
CIM...! :mrgreen: (Read my Sig...)

Hum, being nice as I usually don't answer when FCI is not mentioned, and re-hum..., wondering btw why you opened your Thread in the 'iMacros for FF' Sub-Forum, but yep, simply code one Block and loop it, if you still haven't found the/a Solution by yourself...

=> Like that...: :idea:

Code: Select all

TAG POS=1 TYPE=TD ATTR=CLASS:row_{{!LOOP}}_2 EXTRACT=TXT
TAG POS=1 TYPE=TD ATTR=CLASS:row_{{!LOOP}}_3 EXTRACT=TXT  
=> Or like that...: :idea:

Code: Select all

TAG POS={{!LOOP}} TYPE=TD ATTR=CLASS:row_*_2 EXTRACT=TXT
TAG POS={{!LOOP}} TYPE=TD ATTR=CLASS:row_*_3 EXTRACT=TXT  
(But this is very "basic" Functionality for iMacros, you should have a look at the 'Command Reference' in the Wiki for a list of all Commands, and at the Demo-Macros... :idea: )
- (F)CIM = (Full) Config Info Missing: iMacros + Browser + OS with all 3 Versions...
- I usually don't even read the Question if that (required) Info is not mentioned...
- Script & URL usually help a lot for a more "educated" Help...
Brendo
Posts: 4
Joined: Thu Nov 29, 2018 7:29 pm

Re: Code simplification - class values increase by one

Post by Brendo » Tue May 14, 2019 8:25 am

Thanks for the help! Your option helped me. Sorry for post a topic in the wrong thread :oops:
Post Reply