affilategod 0 Posted March 23, 2014 Report Share Posted March 23, 2014 I need multiple threads that perform the same exact loop. The only difference is that each loop needs its own unique variable names so that they do not interfere with each other. Took me 12 hours to figure out this problem by the way -.- I know that generally setting up multiple threads would be like this: Loop #threadLoop# Script but, this duplicates it exactly and I don't have the ability to put variables in variable names to increment the id's by 1 each time. I really want to be able to give the user the ability to choose the amount of threads he/she would want running at once, but the only idea I can think of is letting them reopen the exe's and run multiple exe's. Any ideas? Quote Link to post Share on other sites
Bot-Factory 602 Posted March 23, 2014 Report Share Posted March 23, 2014 Hi. Put the code you want to execute in a thread into a define command.Then you start a new thread calling that define and sending the necessary variables to it: set(#active threads, $plugin function("Threads Counter.dll", "threads counter", "reset"), "Global")set list position(%userurl, 0)loop($list total(%userurl)) { loop while($comparison($plugin function("Threads Counter.dll", "threads counter", "read"), ">=", 25)) { wait(0.5) } set(#active threads, $plugin function("Threads Counter.dll", "threads counter", "increment"), "Global") filterresults($next list item(%userurl))} define filterresults(#nextitem) { thread { comment("THREAD COMMANDS HERE") set(#active threads, $plugin function("Threads Counter.dll", "threads counter", "decrement"), "Global") }} Please let me know if something is unclear. Or post your code where you run into problems. Dan Quote Link to post Share on other sites
affilategod 0 Posted March 24, 2014 Author Report Share Posted March 24, 2014 Thanks for the reply. I'm trying to copy paste your code into ubot to get a better visual, but every time I copy paste the code and switch to node view, I get "assertion failed". Then ubot closes. Also, would this give each thread the same variables, but with unique names? For example: Thread 1Set VariableA1Set VariableB1 Thread 2Set VariableA2Set VariableB2 Thread 3Set VariableA3Set VariableB3 etc The reason I need them to have different name is because some of the variables scrape the html for an ID that changes every time a thread loops and this ID is needed to perform the task that I'm trying to accomplish. Also, could the global and local options help with this? I'm not totally sure how local and global works. Maybe if I do this Loop [Variable #userdecidesthreads]ThreadLoop[Variable #userdecidesloops] Set all variables localthe rest of my script Would making each variable local make them only respond in the thread that they are in?edit: After researching this, the answer is no lol So another question. If I define a function or command(still trying to understand the difference) with my script, and set all variables to local, then create the loop, thread, loop logic and in the loops call the command. Would each loop hold local variables since those variables are in a defined command? I'm using http sockets, so it's hard to test this. Quote Link to post Share on other sites
Bot-Factory 602 Posted March 24, 2014 Report Share Posted March 24, 2014 Hi. There was a little error in the code. I removed one line. You also need the threads plugin:http://www.ubotstudio.com/forum/index.php?/topic/15441-free-plugin-threads-counter-ubot-v4-threading-fixed/ And you definately should use Ubot Version4 for this. I haven't tested it with V5 Dan Quote Link to post Share on other sites
affilategod 0 Posted March 25, 2014 Author Report Share Posted March 25, 2014 I just bought the program. Is there a way to use 4? Quote Link to post Share on other sites
affilategod 0 Posted March 25, 2014 Author Report Share Posted March 25, 2014 Okay, so my strategy worked with an idea influenced by you! Thank you This is what I did. Lets say you want multiple threads with the same exact loop in it, but want your variables to work in their specific thread alone without having to have separate threads with renamed variables. Define command[named command]loop[number]Script here(make sure to set all variables and/or lists to local) Loop[Number]threadin new browser[named command] Quote Link to post Share on other sites
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.