How to continue using record in csv after if condition in JS

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.

Moderators: Community Moderators, iMacros Moderators

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.

How to continue using record in csv after if condition in JS

by ledchoi on Fri May 05, 2017 11:30 pm

Hello, my problem is I can not call or use record I called before using iimplay(). I have to handle some record in csv and then add to iimplay to continue running but it's still keep the data I called. This is a part of my CODES
var ProductsTypeArray = [];
var load;
var i=1;
load = "CODE:";
load += "SET !DATASOURCE export.csv"+ "\n";
load += "SET !DATASOURCE_COLUMNS 9" + "\n";
load += "SET !DATASOURCE_LINE {{i}}" + "\n";
load += "SET !EXTRACT null" + "\n";
load += "SET !EXTRACT {{!COL2}}" + "\n";
iimSet("i",i);
iimPlay(load);
ProductsTypeArray.push(iimGetLastExtract(1));
iimDisplay(ProductsTypeArray[0]);
if(ProductsTypeArray[0]==null)
{
iimDisplay("Upload Done!")
}
else if(ProductsTypeArray[0]=="T-shirt")
{
var loadAdd;
loadAdd+="CODE:";
loadAdd+="TAB T=1"+ "\n";
loadAdd+="URL GOTO=https://www.printful.com/dashboard/store"+ "\n";
loadAdd+="TAG POS=1 TYPE=A ATTR=TXT:Add"+ "\n";
loadAdd+="EVENT TYPE=CLICK SELECTOR=\"HTML>BODY>DIV:nth-of-type(9)>DIV>DIV>DIV:nth-of-type(2)>DIV>DIV>DIV>DIV>DIV>A>DIV>DIV>DIV\" BUTTON=0"+ "\n";
loadAdd+="TAG POS=1 TYPE=IMG ATTR=SRC:https://d1yg28hrivmbqm.cloudfront.net/upload/category/ca/ca3f866e1670b0694fe2a101b68300fe_t?v=1483603495"+ "\n";
loadAdd+="EVENT TYPE=CLICK SELECTOR=\"HTML>BODY>DIV:nth-of-type(9)>DIV>DIV>DIV:nth-of-type(2)>DIV>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV>DIV>DIV>DIV\" BUTTON=0"+ "\n";
loadAdd+="TAG POS=1 TYPE=A ATTR=TXT:Choose<SP>file"+ "\n";
loadAdd+="TAG POS=1 TYPE=DIV ATTR=ID:library-search-1_tagsinput"+ "\n";
loadAdd+="TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:library-search-1_tag CONTENT={{!COL3}}"+ "\n"; ERROR RIGHT HERE! WHEN IIMPLAY(loadAdd) IS RUNNING, {{!COL3}} is undefined
loadAdd+="EVENT TYPE=KEYPRESS SELECTOR=\"#library-search-1_tag\" KEY=13"+ "\n";
loadAdd+="WAIT SECONDS=1"+ "\n";
iimPlay(loadAdd);
}
}
Win 7 64bit
Imarcros ver 9.0.3
Firefox 53
ledchoi
 
Posts: 8
Joined: Wed Mar 29, 2017 11:00 am

Re: How to continue using record in csv after if condition i

by chivracq on Sat May 06, 2017 11:04 am

ledchoi wrote:
Code: Select all
Win 7 64bit
Imarcros ver 9.0.3
Firefox 53


Hello, my problem is I can not call or use record I called before using iimplay(). I have to handle some record in csv and then add to iimplay to continue running but it's still keep the data I called. This is a part of my CODES
Code: Select all
var ProductsTypeArray = [];
var load;
var i=1;
load =  "CODE:";
load +=  "SET !DATASOURCE export.csv"+ "\n";
load +=  "SET !DATASOURCE_COLUMNS 9" + "\n";
load +=  "SET !DATASOURCE_LINE {{i}}" + "\n";
load +=  "SET !EXTRACT null" + "\n";
load +=  "SET !EXTRACT {{!COL2}}" + "\n";
iimSet("i",i);
iimPlay(load);
ProductsTypeArray.push(iimGetLastExtract(1));
iimDisplay(ProductsTypeArray[0]);
if(ProductsTypeArray[0]==null)
{
 iimDisplay("Upload Done!")
}
else if(ProductsTypeArray[0]=="T-shirt")
{
var loadAdd;
loadAdd+="CODE:";
loadAdd+="TAB T=1"+ "\n";
loadAdd+="URL GOTO=https://www.printful.com/dashboard/store"+ "\n";
loadAdd+="TAG POS=1 TYPE=A ATTR=TXT:Add"+ "\n";
loadAdd+="EVENT TYPE=CLICK SELECTOR=\"HTML>BODY>DIV:nth-of-type(9)>DIV>DIV>DIV:nth-of-type(2)>DIV>DIV>DIV>DIV>DIV>A>DIV>DIV>DIV\" BUTTON=0"+ "\n";
loadAdd+="TAG POS=1 TYPE=IMG ATTR=SRC:https://d1yg28hrivmbqm.cloudfront.net/upload/category/ca/ca3f866e1670b0694fe2a101b68300fe_t?v=1483603495"+ "\n";
loadAdd+="EVENT TYPE=CLICK SELECTOR=\"HTML>BODY>DIV:nth-of-type(9)>DIV>DIV>DIV:nth-of-type(2)>DIV>DIV>DIV:nth-of-type(2)>DIV:nth-of-type(2)>DIV>DIV>DIV>DIV\" BUTTON=0"+ "\n";
loadAdd+="TAG POS=1 TYPE=A ATTR=TXT:Choose<SP>file"+ "\n";
loadAdd+="TAG POS=1 TYPE=DIV ATTR=ID:library-search-1_tagsinput"+ "\n";
[b]loadAdd+="TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:library-search-1_tag CONTENT={{!COL3}}"+ "\n"; ERROR RIGHT HERE! WHEN IIMPLAY(loadAdd) IS RUNNING, {{!COL3}} is undefined[/b]
loadAdd+="EVENT TYPE=KEYPRESS SELECTOR=\"#library-search-1_tag\" KEY=13"+ "\n";
loadAdd+="WAIT SECONDS=1"+ "\n";
iimPlay(loadAdd);
}
}

Win 7 64bit
Imarcros ver 9.0.3
Firefox 53

ERROR RIGHT HERE! WHEN IIMPLAY(loadAdd) IS RUNNING, {{!COL3}} is undefined
Code: Select all
loadAdd+="TAG POS=1 TYPE=INPUT:TEXT ATTR=ID:library-search-1_tag CONTENT={{!COL3}}"+ "\n";

Well, 2 Pb's here I think...
First, I think your '!COL3' contains the Path to your File to upload, from what I understand from your Script, and because you are using the on-the-fly Syntax to build your Macro, you would need to escape the Backslashes in your Path by doubling them. Or you can replace the Backslashes in the Path with Forward Slashes.
If your Path contains Spaces, those could cause a Pb as well, and you would need to replace them with '<SP>' or to enclose your '{{!COL3}}' with Double Quotes..., that would need to be escaped as well.

Secondly, the File Upload Functionality is not supported by iMacros for FF v9.0.3 anymore, you would need to revert to v8.9.7 (which is more stable than v9.0.3 anyway, and still works on FF53).
- (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...
chivracq
 
Posts: 6490
Joined: Sat Apr 13, 2013 6:07 am
Location: Amsterdam (NL)


Return to Scripting and Command Line Interface

Who is online

Users browsing this forum: No registered users and 3 guests

-->