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 Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.
Post Reply
Brendo
Posts: 1
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: 8039
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...
Post Reply