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++.
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
ledchoi
Posts: 8
Joined: Wed Mar 29, 2017 6:00 pm

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

Post by ledchoi » Sat May 06, 2017 6:30 am

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/u ... 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
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

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

Post by chivracq » Sat May 06, 2017 6:04 pm

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)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...
Post Reply