i'm try to copy some text list and paste to wordpress categories with checkbox, with some condition.
copy source in TAB 1:
TAB T=1
TAG POS=1 TYPE=LI ATTR=CLASS:entry-category EXTRACT=TXT
SET !VAR1 {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=2 TYPE=LI ATTR=CLASS:entry-category EXTRACT=TXT
SET !VAR2 {{!EXTRACT}}
SET !EXTRACT NULL
TAG POS=3 TYPE=LI ATTR=CLASS:entry-category EXTRACT=TXT
SET !VAR3 {{!EXTRACT}}
SET !EXTRACT NULL
paste text with checkbox on TAB 2:
TAB T=2
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:post ATTR=ID:in-category-3 CONTENT=YES
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:post ATTR=ID:in-category-6 CONTENT=YES
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:post ATTR=ID:in-category-9 CONTENT=YES
condition:
IF (!VAR1 = TEXT1) {TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:post ATTR=ID:in-category-3 CONTENT=YES}
IF (!VAR1 = TEXT2) {TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:post ATTR=ID:in-category-6 CONTENT=YES}
IF (!VAR1 = TEXT3) {TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:post ATTR=ID:in-category-9 CONTENT=YES}
IF (!VAR1 = #EANF#) {DO NOTHING}
how to make imacros with that condition? thanks.
edit: Thanks Naren Murali for your answer, but worked only for first checkbox, can't several checkbox. We want Tab1 for copy and Tab2 for paste. From your answer Text1, Text2, Text3 looks very sensitive, can read Text1 but can't TEXT1, can we make to not sensitive? . Note: On tab1 extract some text list in to different variable in one time then go to tab2 check/tick several checkbox with match condition also in one time.
This should help you. First, IMacros cannot do if condition, so we need to create a javascript file (*.js
) and call IMacros code inside it, as seen in the below code. Let me explain one if
condition, the other two are based on the same, so the code for one if is.
iimPlay(macro1);
var variableOne = iimGetLastExtract();
if(variableOne === textOne){
iimSet("j",3);
iimPlay(output);
}
So first we will play macro1
which is IMacros code, in the below code, we can see the syntax for defining IMacros code in Javascript. So after calling, we need to get the extract obtained from IMacros into javascript for validation, this is done by the command iimGetLastExtract()
which will fetch the extracted value and assign it to the variable (variableOne
), then we have the if condition which checks if the necessary condition is met!
If the condition is met, then we need to pass the category
number, to pass data from Javascript to IMacros, we can use the command iimSet("j",3)
which assigns a number to the variable j
, then we just play the macro output
which will do the selection using iimPlay(output)
. The same is repeated for the other if conditions.
Note: Please don't forget to save this content inside a script.js
file and run it in the IMacros window.
CODE:
var macro1;
macro1 = "CODE:";
macro1 += "SET !ERRORIGNORE YES" + "\n";
macro1 += "SET !EXTRACT NULL" + "\n";
macro1 += "TAG POS=1 TYPE=LI ATTR=CLASS:entry-category EXTRACT=TXT" + "\n";
var macro2;
macro2 = "CODE:" + "\n";
macro2 += "SET !ERRORIGNORE YES" + "\n";
macro2 += "SET !EXTRACT NULL" + "\n";
macro2 += "TAG POS=2 TYPE=LI ATTR=CLASS:entry-category EXTRACT=TXT" + "\n";
var macro3;
macro3 = "CODE:" + "\n";
macro3 += "SET !ERRORIGNORE YES" + "\n";
macro3 += "SET !EXTRACT NULL" + "\n";
macro3 += "TAG POS=3 TYPE=LI ATTR=CLASS:entry-category EXTRACT=TXT" + "\n";
var output;
output = "CODE:";
output += "SET !ERRORIGNORE YES" + "\n";
output += "TAG POS=1 TYPE=INPUT:CHECKBOX FORM=ID:post ATTR=ID:in-category-{{j}} CONTENT=YES" + "\n";
textOne = "Text1";
textTwo = "Text2";
textThree = "Text3";
iimPlay(macro1);
var variableOne = iimGetLastExtract();
if(variableOne === textOne){
iimSet("j",3);
iimPlay(output);
}
iimPlay(macro2);
var variableTwo = iimGetLastExtract();
if(variableTwo === textTwo){
iimSet("j",6);
iimPlay(output);
}
iimPlay(macro3);
var variableThree = iimGetLastExtract();
if(variableThree === textThree){
iimSet("j",9);
iimPlay(output);
}