Loop if until ...

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
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
MAG
Posts: 3
Joined: Tue Jun 19, 2012 9:54 am

Loop if until ...

Post by MAG » Tue Jun 19, 2012 10:16 am

Hello,
I'm wondering if any body can help me on this matter.
in the page of a game there is 20 rows for auction, some of them has buyer and some no.
how can i give a command if "there is no row with 0 buyer go next page"
Thank you in advance

Code: Select all

VERSION BUILD=4010208 RECORDER=CRVERSION  
TAB T=1
	'Certain number of buyers for its auction."0=Nobuyer"
	SET !VAR1 0
'My target price for each unit."2 silver coins"
	SET !VAR2 2
	SET !ERRORIGNORE YES
	SET !EXTRACT_TEST_POPUP ON
	FILTER TYPE=IMAGES STATUS=ON
	SET !TIMEOUT_PAGE 6
	SET !TIMEOUT_STEP 0
                'Find row with no buyer.
		TAG POS=1 TYPE=TD ATTR=CLASS:bids&&TXT:{{!VAR1}}
			'Extraction of goods quantity and name without the buyer. 
			'Extraction result:"				12 x Cage			"
				TAG POS=R-1 TYPE=TD ATTR=CLASS:name&&TXT:* EXTRACT=TXT
				'Calculate the amount to participate in the auction
				SET !VAR3 EVAL("var q=\"{{!EXTRACT}}\";q.replace(\"*\",\"\");var qty= parseFloat(q);var price=\"{{!VAR2}}\";var TotalAmount = Math.round( price * qty );TotalAmount")
				'Open that row for put my amount
				TAG POS=R1 TYPE=A ATTR=HREF:*=*&filter=*&a=*&z=*&&CLASS:*&&TXT:*
				'Put my Total Amount. "12 x 2 = 24"
				TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:* ATTR=NAME:maxBid CONTENT={{!VAR3}}
				'Submit
				TAG POS=1 TYPE=BUTTON ATTR=VALUE:*&&TYPE:submit&&TXT:*
				'Clean Extract and Total Amount
				SET !EXTRACT NULL
				SET !VAR3 NULL
' here what can i do ?! to repeat above commands and if no more "0buyer" go below  :lol: 
TAG POS=1 TYPE=IMG ATTR=SRC:img/x.gif&&ALT:next<sp>page&&TXT:
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: Loop if until ...

Post by siniy » Tue Jun 19, 2012 10:53 am

This is dirty and slow. Just repeat the code 20x times in the script.

Code: Select all

TAG POS=1 TYPE=TD ATTR=CLASS:bids&&TXT:{{!VAR1}}
         'Extraction of goods quantity and name without the buyer.
         'Extraction result:"            12 x Cage         "
            TAG POS=R-1 TYPE=TD ATTR=CLASS:name&&TXT:* EXTRACT=TXT
            'Calculate the amount to participate in the auction
            SET !VAR3 EVAL("var q=\"{{!EXTRACT}}\";q.replace(\"*\",\"\");var qty= parseFloat(q);var price=\"{{!VAR2}}\";var TotalAmount = Math.round( price * qty );TotalAmount")
            'Open that row for put my amount
            TAG POS=R1 TYPE=A ATTR=HREF:*=*&filter=*&a=*&z=*&&CLASS:*&&TXT:*
            'Put my Total Amount
            TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:* ATTR=NAME:maxBid CONTENT={{!VAR3}}
            'Submit
            TAG POS=1 TYPE=BUTTON ATTR=VALUE:*&&TYPE:submit&&TXT:*
            'Clean Extract and Total Amount
            SET !EXTRACT NULL
            SET !VAR3 NULL
In the very end put this.

Code: Select all

TAG POS=1 TYPE=IMG ATTR=SRC:img/x.gif&&ALT:next<sp>page&&TXT:
If you can provide the auction url. We may give a better solution.
MAG
Posts: 3
Joined: Tue Jun 19, 2012 9:54 am

Re: Loop if until ...

Post by MAG » Tue Jun 19, 2012 1:15 pm

Dear Siniy,
I did what you said but that was very long script, i'm asking for better solution :D
i used to same , some times there is no buyer and some times there is no Empty buyer it's take a long time to check 20 times for each page.
here you are :http://tx3.travian.com/hero_auction.php ... y&filter=9
but you have to register an account.
THERE IS an account you can login by username --F-- ,and Password:
the server is finished but you can check what is look like.
Regards
Mohammad
Last edited by MAG on Tue Jun 19, 2012 11:36 pm, edited 1 time in total.
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: Loop if until ...

Post by siniy » Tue Jun 19, 2012 2:16 pm

Create script "travian.js" in imacros folder and run it as usual imacros script.
Usage example: http://forum.imacros.net/viewtopic.php?p=47434#p47434

Code: Select all

//Works only with firefox plugin

var iret2=1;
do {
    var macro;
    macro =  "CODE:";
    macro +=  'VERSION BUILD=4010208 RECORDER=CRVERSION ' + "\n";
    macro +=  'TAB T=1' + "\n";
    macro +=  '\'Certain number of buyers for its auction."0=Nobuyer"' + "\n";
    macro +=  'SET !VAR1 0' + "\n";
    macro +=  '\'My target price for each unit."2 silver coins"' + "\n";
    macro +=  'SET !VAR2 2' + "\n";
    macro +=  'SET !EXTRACT_TEST_POPUP ON' + "\n";
    macro +=  'FILTER TYPE=IMAGES STATUS=OFF' + "\n";
    macro +=  'SET !TIMEOUT_PAGE 6' + "\n";
    macro +=  'SET !TIMEOUT_STEP 2' + "\n";
    macro +=  '\'Find row with no buyer.' + "\n";
    macro +=  'TAG POS=1 TYPE=TD ATTR=CLASS:bids&&TXT:{{!VAR1}}' + "\n";
	macro +=  'SET !ERRORIGNORE YES' + "\n";
    macro +=  '\'Extraction of goods quantity and name without the buyer.' + "\n";
    macro +=  '\'Extraction result:"            12 x Cage         "' + "\n";
    macro +=  'TAG POS=R-1 TYPE=TD ATTR=CLASS:name&&TXT:* EXTRACT=TXT' + "\n";
    macro +=  '\'Calculate the amount to participate in the auction' + "\n";
    macro +=  'SET !VAR3 EVAL("var q=\\"{{!EXTRACT}}\\";q.replace(\\"*\\",\\"\\");var qty= parseFloat(q);var price=\\"{{!VAR2}}\\";var TotalAmount = Math.round( price * qty );TotalAmount")' + "\n";
    macro +=  '\'Open that row for put my amount' + "\n";
    macro +=  'TAG POS=R1 TYPE=A ATTR=HREF:*=*&filter=*&a=*&z=*&&CLASS:*&&TXT:*' + "\n";
    macro +=  '\'Put my Total Amount. "12 x 2 = 24"' + "\n";
    macro +=  'TAG POS=1 TYPE=INPUT:TEXT FORM=ACTION:* ATTR=NAME:maxBid CONTENT={{!VAR3}}' + "\n";
    macro +=  '\'Submit' + "\n";
    macro +=  'TAG POS=1 TYPE=BUTTON ATTR=VALUE:*&&TYPE:submit&&TXT:*' + "\n";
	var iret1 = iimPlay(macro);	//Start the script..			
	if (iret1<0)//If no more zeros found, click next page
    {
        var macro;
        macro =  "CODE:";
        macro +=  "TAG POS=1 TYPE=a ATTR=CLASS:next" + "\n";
        iret2 = iimPlay(macro);
    }
	iimDisplay(iret2)
} while (iret2>=0)//If "Next" click fails, last page,stop the script.
MAG
Posts: 3
Joined: Tue Jun 19, 2012 9:54 am

Re: Loop if until ...

Post by MAG » Tue Jun 19, 2012 9:28 pm

Dear Siniy,
Thanks a lot.
it was grate explain to me.
believe me if i tel you more than thousands i saw but it dos not worked
thanks again for your Grate answer.
i was really tired to search again.
more than 2 month i search all the page but always more confuse for my poor mind :D
of course i have 3 problem.
1- i do not have any education of programing lesson!
2- i do not have good age for learn Almost 40!
3- i do not have hand and this one make me tired and crazy.

YOU MAKE ME HAPPY.
ALWAYS BE HAPPY.

Regards,

Mohammad
ToReRo
Posts: 1
Joined: Wed Feb 25, 2015 9:15 pm

Re: Loop if until ...

Post by ToReRo » Wed Feb 25, 2015 10:06 pm

Hello guys,

can someone help me in how to use imacros for travian farming. are there any scripts to write before playing.

from almost a year we r getting this same error in imacros

RuntimeError: element BUTTON specified by CLASS:green<SP>&&ID:button54ee39d8cb27d&&VALUE:start<SP>raid&&TYPE:submit was not found, line 7 (Error code: -921)

the last button was while pressing send raids it is returning to same position and another thing how to re run the farming task again and again. if possible can someone write a script and give me how to run imacros for farming in travian and how to use the script when and where.

thanks and regards

harsha
Post Reply