Need help with javascript

Find a consultant or advertise your services here
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
Post Reply
super_hiro
Posts: 15
Joined: Tue Feb 23, 2010 2:06 pm

Need help with javascript

Post by super_hiro » Tue Mar 30, 2010 4:28 am

Hi,

I'm working on this particular website that's like ebay where you list your items for sale. I have three IIMs. Loginiim, listitemsiim, and logoutiim.

The listitemsiim pulls the data from a csv file I created. Right now because I can't find a automated process on how to do repeat automatically, I'm having to select how many times to repeat the current macro by using the iMacros toolbar on Firefox and click on Play (Loop).

I want to completely automate the whole process of logging in, listing the items, and log out.

I've written a simple javascript below:

Code: Select all

retcode = iimPlay("login");
for (i = 0; i <50; i++) {
retcode = iimPlay("listitemsiim");}
retcode = iimPlay("logoutiim");
The script works except that on listitemsiim, it does not pull data from 2,3,4 row and so on. It list my item but only the first row. the list itemsiim looks something like this

Code: Select all

SET !DATASOURCE C:\myitems.csv
SET !DATASOURCE_COLUMNS 18
SET !DATASOURCE_LINE {{!LOOP}}
My plan is to make one javascript to put all three iim in there. Afterwards, I'm hoping to create a bookmark of it and schedule to launch using windows sometime of the day.

Please help me if you can for free or give me a quote with a solution. I'll be very happy if you can teach me few tricks also (like how to make the script wait random amount of minutes so that it doesn't seem like i'm using something to automate my listing).

Thank you, and if you need any more details, please let me know.
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: Need help with javascript

Post by Daniel, Tech Support » Tue Mar 30, 2010 11:12 am

Hello,

Let's solve the issues one after one.

Here you're calling this script:

Code: Select all

 retcode = iimPlay("login");
    for (i = 0; i <50; i++) {
    retcode = iimPlay("listitemsiim");}
    retcode = iimPlay("logoutiim");
to play this macro:

Code: Select all

    SET !DATASOURCE C:\myitems.csv
    SET !DATASOURCE_COLUMNS 18
    SET !DATASOURCE_LINE {{!LOOP}}
And it only takes the 1st line of the csv. That's logical, because you use SET !DATASOURCE_LINE {{!LOOP}}, but you don't increase the !LOOP variable, so it always equals 1. What you need to change is to add before

Code: Select all

retcode = iimPlay("listitemsiim");
a line, that uses iimSet() to set the loop variable to i. We'll make it a custom variable myLoop. This should look like this:

Code: Select all

 retcode = iimSet("-var_myLoop", cstr(i))
And then of course change

Code: Select all

 SET !DATASOURCE_LINE {{!LOOP}}
to

Code: Select all

 SET !DATASOURCE_LINE {{myLoop}}
Best regards,
Daniel, iOpus Support
Volodath
Posts: 23
Joined: Mon Jan 17, 2011 11:32 pm

Re: Need help with javascript

Post by Volodath » Tue Mar 22, 2011 4:07 pm

Daniel -

I hate to bump and old topic but I haven't been able to get this working. I'm running firefox 3.4 with the 6.7 plugin. I've got the following as the .js file

var ret
var i


retcode = iimPlay("login");
for( var i=0; i<7100; i++){
retcode = iimSet("-var_myLoop", (i))
iimPlay("beast-tableextract-long-test2",7100)}

If !ERRORIGNORE is YES then this works fine and runs through the script the appropriate number of times.

However, if it's set to NO it times out with an error about the variable 'myloop' not being defined.

If I change the code to
retcode = iimSet("-var_myLoop", cstr(i))

I get the error 'cstr' is not defined. What am I doing wrong?
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: Need help with javascript

Post by Daniel, Tech Support » Wed Mar 23, 2011 1:33 pm

Hi Volodath,

I think part of the problem is that CStr is a visual basic function :). What if you just use i, without (), i.e.

Code: Select all

retcode = iimSet("-var_myLoop", i)
Best regards,
Daniel, iOpus Support
Volodath
Posts: 23
Joined: Mon Jan 17, 2011 11:32 pm

Re: Need help with javascript

Post by Volodath » Wed Mar 23, 2011 4:33 pm

Daniel -

That did the trick, Thank You.

Volo
Daniel, Tech Support
Posts: 1483
Joined: Tue Jan 26, 2010 11:35 am

Re: Need help with javascript

Post by Daniel, Tech Support » Wed Mar 23, 2011 7:36 pm

Hi Volo,

I'm glad it did! You're very welcome!

Best wishes,
Daniel, iOpus Support
Post Reply