Learning Javascript, (break looping when missing tag).

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.

Learning Javascript, (break looping when missing tag).

by GravetoGeek on Tue Sep 27, 2016 12:01 pm

I'm learning javascript and sorry for my grammar, I don't know speak english, but I need to code a while loop but I don't know how to break looping if element INPUT was not found.
I tried to break using iimGetErrorText() but don't work on my purpose.
This is my code:

Code: Select all
var nemesisGuild = [
    "Wings Of Justice",
    "PAX",
   "Memories of Angrathar",
   "Faith",
   "Paradox",
   "Offline",
   "Esquadrão Nôva",
   "Ministry",
   "The perks of being a Pro",
   "Azeroth Heroes",
   "Templários",
   "Special Soldiers",
   "Gnomostocracia",
   "Beco do Tubarão",
   "The Four Horseman",
   "Ordem do Dragão",
   "Ascendancy",
   "Phoenix",
   "Dawn of Victory",
   "Old Dudes",
   "Ascendancy",
   "Loucos de Nescau",
   "Pretorians",
   "Lendas Vivas",
   "The King Slayers",
   "Rising Fury",
   "Titans",
   "The Dragon Hunters",
   "From Chaos to Order",
   "Blue Moon",
   "Círculo de Honra",
   "Sons of LoGosh",
   "Frag or Die",
   "Keepers",
   "Guerreiros Templários",
   "New Legacy",
   "Sons of Arcadia",
   "WoWcólicos",
   "Evolution Warsong",
   "The Wipers",
   "Habeas Corpus",
   "PvP Like A Boss",
   "Dinastia Pandawan",
   "I R M A N Ð A D E",
   "GHOST SOCIETY",
   "The Last Templar",
   "Flagelo Invernal",
   "Herois de Draenor",
   "Osso Duro de HuE",
   "Os Terceiros",
   "Restauração",
   "Scarlet Crusade",
   "Banidos",
   "Evolution",
   "High Latency",
   "Old Clowns",
   "Guardiões",
   "Exilados",
   "Máquina de Guerra",
   "BedPlayers",
   "Glory of C O M A N D O",
   "Guardians of Elune",
   "Seek And Destroyer",
   "Harvest of Sorrow",
   "Bloody Legacy",
   "DarknessOrig Guild",
   "Legião de Nemesis",
   "Sons of Arcadia",
   "Lótus Negra",
   "TEAM DEATH",
   "Persona",
   "The Wipers",
   "Testemunhas de Sargeras",
   "voljin MORREU BANGUELA",
   "The Revenge",
   "Blood Effect",
   "Unkillables",
   "Evolution Warsong",
   "Sagazes",
   "Malfeitores",
   "Dragons Slayers",
   "Debauchery TeaParty",
   "Anjøs da Mørte",
   "Fus Ro Dah",
   "Wolfsbane",
   "Lança Nëgra",
   "Lørd off Gladïators",
   "Death Sky",
   "Isômeros de Stormwind",
   "The Last Hope",
   "Warsong Knights",
   "Filhos de Torosso",
   "Odeia Você",
   "Raid Rock Café",
   "QUEREMOS TRETA",
   "Azeroth",
   "Fúria de Azeroth",
   "Death Vanquisher",
   "O Pacto",
   "Søns øf Hørde",
   "Bloodbrother",
   "The Supremacy",
   "A Fúria de Lordaeron",
   "M A S S A C R E",
   "Mad Lions",
   "Red Sky",
   "LigaBR",
   "Irmãøs De Guerra",
   "For Honor",
   "Cavaleiros da Cruzada",
   "Los Doteiros",
   "Guardião de Azeroth",
   "Ultimato",
   "Villains Øf Hønør",
   "Ïnnova",
   "Crusader",
   "Enraged"
];

var count = 300;
var i;
var j;
var updateButton = "CODE:";
updateButton += "TAG POS=1 TYPE=INPUT:BUTTON ATTR=*" + "\n";
updateButton += "WAIT SECONDS=1" + "\n";

var macro = "CODE:";
macro += "SET !ERRORIGNORE YES" + "\n";
macro += "SET !TIMEOUT_TAG 0" + "\n";
macro += "TAG POS={{j}} TYPE=INPUT:CHECKBOX ATTR=* CONTENT=YES" + "\n";

var url = "CODE:";
url += "URL GOTO=http://www.wowprogress.com/update_progress/us/nemesis/{{g}}" + "\n";

for (i = 0; i < nemesisGuild.length; i++) {
   iimSet("g", nemesisGuild[i]);
   iimPlay(url);
   iimDisplay("Passo " + (i + 1) + " de " + nemesisGuild.length + "\n" + "Macro: " + nemesisGuild[i]);
   
    for (j = 0; j <= count; j++) {
        iimSet("j", j);
        iimPlay(macro);
        iimDisplay("Passo " + (j) + " de " + count + "\n" + "Guilda " + (i + 1) + " de " + nemesisGuild.length + "\n" + "Atualização de " + nemesisGuild[i] + " em progresso.");

    }
   
    iimPlay(updateButton);
    iimDisplay("Passo " + (i + 1) + " de " + nemesisGuild.length + "\n" + "Atualização de " + nemesisGuild[i] + " finalizada com sucesso.");
   report  =  "Guilda " + nemesisGuild[i] + " Atualizada\n\n";
   
    /*
alert ( report );
*/
   
}



I'm using a count for 300 TAG INPUT and I lose a lot of time when url return a few TAG's, I can't predict how many TAG's I need.
I tried to change:

Code: Select all
    for (j = 0; j <= count; j++) {
        iimSet("j", j);
        iimPlay(macro);
        iimDisplay("Passo " + (j) + " de " + count + "\n" + "Guilda " + (i + 1) + " de " + nemesisGuild.length + "\n" + "Atualização de " + nemesisGuild[i] + " em progresso.");

    }


for:

Code: Select all
        while ( iimGetErrorText(macro) >0 ){
            j++;
            iimSet("j", j);
            iimPlay(macro);
            iimDisplay("Passo " + (j) + " de " + count + "\n" + "Guilda " + (i + 1) + " de " + nemesisGuild.length + "\n" + "Atualização de " + nemesisGuild[i] + " em progresso.");
    }


but don't work, can someone help me solve?
GravetoGeek
 
Posts: 2
Joined: Fri Mar 18, 2016 7:23 pm

Re: Learning Javascript, (break looping when missing tag).

by iimfun on Wed Sep 28, 2016 1:51 am

Try to make the following changes
Code: Select all
var macro = "CODE:";
macro += "SET !TIMEOUT_STEP 0" + "\n";
macro += "TAG POS={{j}} TYPE=INPUT:CHECKBOX ATTR=* CONTENT=YES" + "\n";

and
Code: Select all
var j = 1;
do {
   iimSet("j", j);
   var ret = iimPlay(macro);
   iimDisplay("Passo " + (j) + " de " + count + "\n" + "Guilda " + (i + 1) + " de " + nemesisGuild.length + "\n" + "Atualizacao de " + nemesisGuild[i] + " em progresso.");
   j++;
} while (ret == 1)
iimfun
 
Posts: 239
Joined: Tue Jul 19, 2016 6:06 am

Re: Learning Javascript, (break looping when missing tag).

by GravetoGeek on Wed Sep 28, 2016 2:32 am

iimfun wrote:Try to make the following changes
Code: Select all
var macro = "CODE:";
macro += "SET !TIMEOUT_STEP 0" + "\n";
macro += "TAG POS={{j}} TYPE=INPUT:CHECKBOX ATTR=* CONTENT=YES" + "\n";

and
Code: Select all
var j = 1;
do {
   iimSet("j", j);
   var ret = iimPlay(macro);
   iimDisplay("Passo " + (j) + " de " + count + "\n" + "Guilda " + (i + 1) + " de " + nemesisGuild.length + "\n" + "Atualizacao de " + nemesisGuild[i] + " em progresso.");
   j++;
} while (ret == 1)



Thank you so much iimfun, worked perfectly, I'm very grateful for your help.
GravetoGeek
 
Posts: 2
Joined: Fri Mar 18, 2016 7:23 pm


Return to Scripting and Command Line Interface

Who is online

Users browsing this forum: No registered users and 3 guests

-->