Jump to content



Photo

Problem With Combination Of Loop And If And Comparison

loop if comparison csv

  • Please log in to reply
6 replies to this topic

#1 Fruchtwein

Fruchtwein

    Newbie

  • Members
  • Pip
  • 4 posts
  • OS:Windows 8
  • Total Memory:< 1Gb
  • Framework:v3.5
  • License:Developer Edition

Posted 21 June 2016 - 10:09 PM

Hi,

 

I work now many hours on this, but couldn't figure out the correct solution.Maybe someone could help me please?

 

I want my bot to read out CSV file and receive email, password and country from it. So far that works and I have three lists in the end with the correct data.

Now I want to start a loop, where the bot checks the country list and do different things depending on the entry at this certain position.

 

In my code example he should go to the Amazon country webpage and put in the correct login data, than close the browser and check the next item in the list for the country and so on.

 

I hope you get, what I want to do :)

 

My code to load and read out the CSV file:

create table from file("C:\\Users\\Martin\\Desktop\\Login.csv",&mytable)
set(#counterLogin,0,"Global")
loop($table total rows(&mytable)) {
    add item to list(%Login,$table cell(&mytable,#counterLogin,0),"Don\'t Delete","Global")
    increment(#counterLogin)
}
remove from list(%Login,0)
create table from file("C:\\Users\\Martin\\Desktop\\Login.csv",&mytable)
set(#counterPW,0,"Global")
loop($table total rows(&mytable)) {
    add item to list(%Pass,$table cell(&mytable,#counterPW,1),"Don\'t Delete","Global")
    increment(#counterPW)
}
remove from list(%Pass,0)
create table from file("C:\\Users\\Martin\\Desktop\\Login.csv",&mytable)
set(#counterLand,0,"Global")
loop($table total rows(&mytable)) {
    add item to list(%Land,$table cell(&mytable,#counterLand,2),"Don\'t Delete","Global")
    increment(#counterLand)
}
remove from list(%Land,0)

My loop code (and I think here is the mistake):

set list position(%Login,0)
set list position(%PW,0)
set list position(%Land,0)
loop($list total(%Login)) {
    if($comparison($next list item(%Land),"= Equals","DE")) {
        then {
            plugin command("ExBrowser.dll", "ExBrowser CleanUp")
            plugin command("ExBrowser.dll", "ExBrowser Launcher", "Chrome", "", "")
            login DEU()
            wait for browser event("DOM Ready","")
            plugin command("ExBrowser.dll", "ExBrowser Close")
        }
        else {
        }
    }
    if($comparison($next list item(%Land),"= Equals","UK")) {
        then {
            plugin command("ExBrowser.dll", "ExBrowser CleanUp")
            plugin command("ExBrowser.dll", "ExBrowser Launcher", "Chrome", "", "")
            login UK()
            wait for browser event("DOM Ready","")
            plugin command("ExBrowser.dll", "ExBrowser Close")
        }
        else {
        }
    }
    if($comparison($next list item(%Land),"= Equals","ES")) {
        then {
            alert("ES!")
        }
        else {
        }
    }
    if($comparison($next list item(%Land),"= Equals","FR")) {
        then {
            alert("FR!")
        }
        else {
        }
    }
    if($comparison($next list item(%Land),"= Equals","IT")) {
        then {
            alert("IT!")
        }
        else {
        }
    }
}

At the moment I only get an error message. If I put in the data in the CSV in the order as I put the code it works out, but than there is no real checking for the country column in the CSV?

 

Thank you very much!

Fruchtwein



#2 pash

pash

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 3299 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 21 June 2016 - 11:19 PM

try

clear all data
create table from file("D:\\Ubot Plugin Development\\Sample\\Advanced Data Text File\\test.csv",&mytable)
add list to list(%Login,$plugin function("TableCommands.dll", "$list from table", &mytable, "Column", 0),"Delete","Global")
add list to list(%Pass,$plugin function("TableCommands.dll", "$list from table", &mytable, "Column", 1),"Delete","Global")
add list to list(%Land,$plugin function("TableCommands.dll", "$list from table", &mytable, "Column", 2),"Delete","Global")
divider
set list position(%Login,1)
set list position(%Pass,1)
set list position(%Land,1)
loop($subtract($list total(%Login),1)) {
    set(#Login,$next list item(%Login),"Global")
    set(#PW,$next list item(%Pass),"Global")
    set(#Land,$next list item(%Land),"Global")
    if($comparison(#Land,"= Equals","DE")) {
        then {
            alert("DE")
        }
        else if($comparison(#Land,"= Equals","UK")) {
            alert("UK")
        }
        else if($comparison(#Land,"= Equals","ES")) {
            alert("ES")
        }
        else {
        }
    }
}


Edited by pash, 22 June 2016 - 12:33 AM.

New Plugin:: Advanced Facebook | Advanced Connection | Advanced Twitter | Advanced Email | Advanced PowerPoint
- Advanced Data Text File | Advanced DateTime | Advanced Dialog | Advanced Document | Advanced Google Blogger V3 | Advanced Google Drive | Advanced Google YouTube V3 | Advanced Image | Advanced Video | Advanced Screen and Windows | Advanced Systems | Advanced Ubot 1 | Advanced Ubot 2 | Advanced WordPress | Advanced Connection | Advanced Twitter | Advanced Email | Advanced PowerPoint

- Advanced Captcha (V3) | Advanced Captcha (V2) (Old) | Create Table From Excel (Lite) | Check Conection | Ubot Enter License | Auto Free Memory
- Working hours GMT+7. i regret sometimes the answer is delayed due to health problems.


#3 Fruchtwein

Fruchtwein

    Newbie

  • Members
  • Pip
  • 4 posts
  • OS:Windows 8
  • Total Memory:< 1Gb
  • Framework:v3.5
  • License:Developer Edition

Posted 21 June 2016 - 11:54 PM

Ciao pash,

 

thanks for your (fast!) help.

 

I now get an error message: "You have exceeded the range of the list."



#4 pash

pash

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 3299 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 21 June 2016 - 11:58 PM

Ciao pash,

 

thanks for your (fast!) help.

 

I now get an error message: "You have exceeded the range of the list."

i edit code. try copy new.


New Plugin:: Advanced Facebook | Advanced Connection | Advanced Twitter | Advanced Email | Advanced PowerPoint
- Advanced Data Text File | Advanced DateTime | Advanced Dialog | Advanced Document | Advanced Google Blogger V3 | Advanced Google Drive | Advanced Google YouTube V3 | Advanced Image | Advanced Video | Advanced Screen and Windows | Advanced Systems | Advanced Ubot 1 | Advanced Ubot 2 | Advanced WordPress | Advanced Connection | Advanced Twitter | Advanced Email | Advanced PowerPoint

- Advanced Captcha (V3) | Advanced Captcha (V2) (Old) | Create Table From Excel (Lite) | Check Conection | Ubot Enter License | Auto Free Memory
- Working hours GMT+7. i regret sometimes the answer is delayed due to health problems.


#5 Fruchtwein

Fruchtwein

    Newbie

  • Members
  • Pip
  • 4 posts
  • OS:Windows 8
  • Total Memory:< 1Gb
  • Framework:v3.5
  • License:Developer Edition

Posted 22 June 2016 - 12:27 AM

i edit code. try copy new.

 

Sorry, still the same. If I cick continue it shows up the alerts in correct order as it is put into the CSV file.

 

(Edit) Also I figured out sometimes the same country is multiple times in the CSV, than it doesn't recognize it. (/Edit)


Edited by Fruchtwein, 22 June 2016 - 12:32 AM.


#6 pash

pash

    Advanced Member

  • Fellow UBotter
  • PipPipPip
  • 3299 posts
  • OS:Windows 10
  • Total Memory:More Than 9Gb
  • Framework:v4.5+, unsure
  • License:Developer Edition

Posted 22 June 2016 - 12:33 AM

edit code 2.

 

Note.

I have no "ExBrowser" so I can not test.
Please wait for an answer from "Dan".


New Plugin:: Advanced Facebook | Advanced Connection | Advanced Twitter | Advanced Email | Advanced PowerPoint
- Advanced Data Text File | Advanced DateTime | Advanced Dialog | Advanced Document | Advanced Google Blogger V3 | Advanced Google Drive | Advanced Google YouTube V3 | Advanced Image | Advanced Video | Advanced Screen and Windows | Advanced Systems | Advanced Ubot 1 | Advanced Ubot 2 | Advanced WordPress | Advanced Connection | Advanced Twitter | Advanced Email | Advanced PowerPoint

- Advanced Captcha (V3) | Advanced Captcha (V2) (Old) | Create Table From Excel (Lite) | Check Conection | Ubot Enter License | Auto Free Memory
- Working hours GMT+7. i regret sometimes the answer is delayed due to health problems.


#7 Fruchtwein

Fruchtwein

    Newbie

  • Members
  • Pip
  • 4 posts
  • OS:Windows 8
  • Total Memory:< 1Gb
  • Framework:v3.5
  • License:Developer Edition

Posted 22 June 2016 - 03:04 AM

edit code 2.

 

Note.

I have no "ExBrowser" so I can not test.
Please wait for an answer from "Dan".

 

Thanks again.

Now the first message appears and when I press ok for that "alert" the same problem pops up.

 

I put

            alert(#Login)
            alert(#PW)

into your code, to check if he uses the right data from CSV file and for the first one he did, than the #PW comes out empty (in my CSV, it is always the same - but won't be in general).

 

I don't have to use ExBrowser, I feel more comfortable with it, but for the testing reason we can use the standard ubot browser.

 

Thanks so much for time and help!







Also tagged with one or more of these keywords: loop, if, comparison, csv

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users