Page 1 of 1

help with inefficient code

Posted: Wed Aug 17, 2011 8:08 pm
by seandamnit
Hello,

I have a set of data in a CSV file that looks like this:

Image

my code looks like this:

Code: Select all

VERSION BUILD=7300701 RECORDER=FX
TAB T=1
SET !DATASOURCE orders.csv
SET !DATASOURCE_COLUMNS 100
SET !ERRORIGNORE YES
TAG POS=1 TYPE=SPAN ATTR=TXT:Phones
SET !TIMEOUT_STEP 0
TAG POS=1 TYPE=LI ATTR=TXT:Item<SP>Code:<SP>{{!COL3}}
SET !TIMEOUT_STEP 0
TAG POS=R1 TYPE=INPUT:TEXT FORM=ACTION:* ATTR=NAME:productRowContainer:* CONTENT={{!COL4}}
SET !TIMEOUT_STEP 0
TAG POS=1 TYPE=LI ATTR=TXT:Item<SP>Code:<SP>{{!COL5}}
SET !TIMEOUT_STEP 0
TAG POS=R1 TYPE=INPUT:TEXT FORM=ACTION:* ATTR=NAME:productRowContainer:* CONTENT={{!COL6}}
SET !TIMEOUT_STEP 0
TAG POS=1 TYPE=LI ATTR=TXT:Item<SP>Code:<SP>{{!COL7}}
SET !TIMEOUT_STEP 0
TAG POS=R1 TYPE=INPUT:TEXT FORM=ACTION:* ATTR=NAME:productRowContainer:* CONTENT={{!COL8}}
SET !TIMEOUT_STEP 0
TAG POS=1 TYPE=LI ATTR=TXT:Item<SP>Code:<SP>{{!COL9}}
SET !TIMEOUT_STEP 0
TAG POS=R1 TYPE=INPUT:TEXT FORM=ACTION:* ATTR=NAME:productRowContainer:* CONTENT={{!COL10}}
SET !TIMEOUT_STEP 0
TAG POS=1 TYPE=LI ATTR=TXT:Item<SP>Code:<SP>{{!COL11}}
SET !TIMEOUT_STEP 0
TAG POS=R1 TYPE=INPUT:TEXT FORM=ACTION:* ATTR=NAME:productRowContainer:* CONTENT={{!COL12}}
SET !TIMEOUT_STEP 0
TAG POS=1 TYPE=LI ATTR=TXT:Item<SP>Code:<SP>{{!COL13}}
SET !TIMEOUT_STEP 0
TAG POS=R1 TYPE=INPUT:TEXT FORM=ACTION:* ATTR=NAME:productRowContainer:* CONTENT={{!COL14}}
SET !TIMEOUT_STEP 0
TAG POS=1 TYPE=LI ATTR=TXT:Item<SP>Code:<SP>{{!COL15}}
SET !TIMEOUT_STEP 0
TAG POS=R1 TYPE=INPUT:TEXT FORM=ACTION:* ATTR=NAME:productRowContainer:* CONTENT={{!COL16}}
SET !TIMEOUT_STEP 0
TAG POS=1 TYPE=LI ATTR=TXT:Item<SP>Code:<SP>{{!COL17}}
SET !TIMEOUT_STEP 0
TAG POS=R1 TYPE=INPUT:TEXT FORM=ACTION:* ATTR=NAME:productRowContainer:* CONTENT={{!COL18}}
This will loop through an order form and auto order product...first finding the specific product SKU, then entering an order qty in the first text box after that product SKU.

I'm looking to make this more efficient and user friendly. Right now you'll see that I enter enough lines of code to cover the max amount of columns I have in the data set, and use TIMEOUT_STEP to skip blank data. While that seems to work as a stop gap, it is unfortunately slower than I'd like, as rows with only 1 product to order still need to run through x more unnecessary steps, and it requires me to update the lines of code depending on my max columns (which will change every time I run this).

Using Firefox

Any suggestions?

Re: help with inefficient code

Posted: Thu Aug 18, 2011 12:08 pm
by MattBell7
easiest option would be to split each item onto seperate lines so with your data you 'd have something more like this:

A1,B1,C1,D1
A1,B1,E1,F1
A1,B1,G1,H1
A2,B2,C2,D2

then your macro won't try to process blank cells, it'll only do what it needs.

The best solution would be to use the scripting interface to control iMacros with variable length loops. but that will be a lot more complex

Re: help with inefficient code

Posted: Thu Aug 18, 2011 5:08 pm
by seandamnit
MattBell7 wrote:easiest option would be to split each item onto seperate lines so with your data you 'd have something more like this:

A1,B1,C1,D1
A1,B1,E1,F1
A1,B1,G1,H1
A2,B2,C2,D2

then your macro won't try to process blank cells, it'll only do what it needs.

The best solution would be to use the scripting interface to control iMacros with variable length loops. but that will be a lot more complex
How would I make this loop, with the data organized as your propose? I've organized the data in this manner so that each store's orders are on one line, to make looping possible (I didn't include code for the rest of the script, where it selects a shipping destination and confirms the order)

I don't have the scripting edition, and unfortunately would not be able to justify the cost to my company

Re: help with inefficient code

Posted: Fri Aug 19, 2011 9:45 am
by MattBell7
right, in that case, don't change the format.

in can be done with the freeware version, you'll need to use the Firefox Scripting interface. Have a look on the wiki and it'll show you how.