Jump to content
UBot Underground

Variables Scopes and Threads


Recommended Posts

Hello,

 

1) I have a list of 10 users in a CSV file.

 

2) All users are loaded into a table and each row launch a new thread(login, etc)

 

3) Each thread scraps some data and post to a site(this info is in the table too, from the CSV)

 

The CSV is like this:

 

user, url, category

 

So we have the username, the pass is harcoded, the url to scrape, and the category to post it

 

My question is this:

 

The tables are global?

The "Define" command, its params are pased by reference o by value?

The login one works file ...

 

But the poster, seems to screw the table somehow ... or the lists

cell(&users, #counter, 1) is the origin url to scrape to

cell(&users, #counter, 2) is the category to post it in my site

create table from file("orders.txt", &users)
set(#counter, 0, "Global")
loop($table total rows(&users)) {
    thread {
        in new browser {
            Login Pinterest($table cell(&users, #counter, 0), "single password here")
            Poster($table cell(&users, #counter, 1), $table cell(&users, #counter, 2))
        }
        increment(#counter)
    }
}

Inside the defined POSTER I build a list of scraped values, are those list local to each thread? I have set them to "LOCAL" but I cant find documentation about scopes of variables to get it right.

 

Seems to me that each thread is overwriting the "LOCAL" list ... of the other threads

 

Thanks.

 

 

 

Link to post
Share on other sites

I'm not sure if this will fully answer your question but it may help you to understand better:

 

Global means it is seen and used by everything. So when you have a global table each thread can see everything in the table and interact with it.

 

Local means that only that one thread can see it. So when you have a local list for example you don't need to clear it because it is being created and at the end of the thread it is destroyed. No other thread can interact with it so that means if you want to keep the data you need to eventually add it to a global list or save it out in each instance of the threads.

Link to post
Share on other sites

Values. Take a look at this:

set(#number, 0, "Global")
add num(10)
define add num(#number) {
    set(#number, 50, "Global")
}

You will see that the #number changes because it is global if it were local it would not show up because it would be local to the command or thread. Just like I did here, you can see that #number will remain 0 but it is returned as 50 because it is set to local (but you won't see it change to 50 in the debugger)

set(#number, 0, "Global")
set(#result, $add num(#number), "Global")
define $add num(#number) {
    set(#number, 50, "Local")
    return(#number)
}

Link to post
Share on other sites

The problem with your code is that you increment "#counter" inside the thread, so it stays the same till thread finishes (that's why most if not all threads use value 0 as "#counter).

 

Instead you should move "#counter" outside from the thread and wrap the whole thread node in define command and pass #counter value as parameter.

 

If you don't pass "#counter" as parameter, the thread could use a wrong value, since you would first spawn a thread which takes almost zero time, and then you would increment "#counter" (outside thread), which would then be used by thread you spawned (for example, when you start bot "#counter" has value 0, but as soon as thread is spawned, that global variable value changes to 1, and 1 is the value that is used inside first thread, where bot should be using "counter = 0" ).

Link to post
Share on other sites

UbotDev.com, yes eventualy I came up with that ... Now I have 10 instances running like a charm.

Thanks for all the help ... I just get the PRO, so I'm new in Ubot threads ...

Link to post
Share on other sites

UbotDev.com, yes eventualy I came up with that ... Now I have 10 instances running like a charm.

Thanks for all the help ... I just get the PRO, so I'm new in Ubot threads ...

OK, nice....according to your previous reply I thought that it's still unclear to you, that's why I wanted to explain. Good luck with your projects! :)

 

I also note that here in the forum still says "License: Standard" :)

I didn't even notice that... however, I believe you need to change that manually.

Link to post
Share on other sites

OK, nice....according to your previous reply I thought that it's still unclear to you, that's why I wanted to explain. Good luck with your projects! :)

 

I didn't even notice that... however, I believe you need to change that manually.

 

Indeed, It was .. thanks for all the clarifications. :)

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...