mamica 10 Posted January 2, 2014 Report Share Posted January 2, 2014 As the title say, i have 500 variables, and i have info for them in a list in correct order. So now if i want to set up each variable i need to use set(#variblae, "something", "Global") So for 500 variables i need 500 lines (now what if i have 1000? or 10000 variables? So best deal is to save variable list in ubot lists and then loop each variable and set the correct info:But problem is that i cant set a variable from a list. When using command SET we are not allowed to insert a next list item in variable name. Can we bypass this somehow or there is some other way to fix this issue? Quote Link to post Share on other sites
the_way 52 Posted January 2, 2014 Report Share Posted January 2, 2014 create a loop while, set a variable to list item 0, make sure your variable is something like #variable + incremenent id number, then as loop works, you'll get variables called: variable1, variable2 Quote Link to post Share on other sites
Gogetta 263 Posted January 2, 2014 Report Share Posted January 2, 2014 This can't be done using the regular set variable command. Even the way that quite_interesting explains it is not possible. Why not just use the table cell like a variable. Just think the logic out beforehand and you can set or call each table cell from inside of a loop, or at anytime using the row and column number. Small example: This example requires UbotDev's free plugin ui stat monitor("Threads Open:", #threads_track) clear table(&my_table) set(#running, "true", "Global") comment("This thread is running just for reports.") thread { loop while($comparison(#running, "=", "true")) { run_reports() wait(0.5) } } set(#row, 0, "Global") set(#threads_track, $plugin function("Threads_Counter[1].dll", "threads counter", "reset"), "Global") loop(100) { comment("handoff is used to tell the script when the #row variable isnt in use and can be incremented for the next thread.") set(#handoff, "true", "Global") set(#threads_track, $plugin function("Threads_Counter[1].dll", "threads counter", "increment"), "Global") thread { comment("Launching100 threads with each define reporting back to its unique variable (table cell).") counter(#row) set(#threads_track, $plugin function("Threads_Counter[1].dll", "threads counter", "decrement"), "Global") } loop while($comparison(#handoff, "=", "true")) { wait(0.1) } increment(#row) } loop while($comparison(#threads_track, ">", 0)) { wait(0.5) } thread { alert("Finished!") } set(#running, "false", "Global") run_reports() stop script define run_reports { set(#row, 0, "Local") clear list(%reports) set(#thread_count, 1, "Local") loop($table total rows(&my_table)) { add item to list(%reports, "Thread {#thread_count}: {$table cell(&my_table, #row, 0)}", "Delete", "Global") increment(#row) increment(#thread_count) } load html($replace($text from list(%reports, $new line), $new line, "<br/>")) } define counter(#variable_number) { set(#handoff, "false", "Global") set(#number, 0, "Local") comment("Counting to 10 with a random wait time between 1-10 seconds.") loop(10) { set(#random_wait, $rand(1, 10), "Global") set table cell(&my_table, #variable_number, 0, "{#number} (resting for {#random_wait} seconds)") wait(#random_wait) increment(#number) } set table cell(&my_table, #variable_number, 0, "Done!") } This is just a basic example of how it is possible to create a log of 100 or more threads with each thread reporting back a separate status. 1 Quote Link to post Share on other sites
blumi40 222 Posted January 2, 2014 Report Share Posted January 2, 2014 create a loop while, set a variable to list item 0, make sure your variable is something like #variable + incremenent id number, then as loop works, you'll get variables called: variable1, variable2Show me that as ubot code plsthx 1 Quote Link to post Share on other sites
pftg4 102 Posted January 3, 2014 Report Share Posted January 3, 2014 you can use my Dynamic variables and set all with one node in under a second hope this helps http://www.screencast.com/users/pftg4/folders/Jing/media/d21b3912-f766-474a-8c50-ab154521818b 2 Quote Link to post Share on other sites
mamica 10 Posted January 3, 2014 Author Report Share Posted January 3, 2014 i m not sure if we understand each other. I have check dynamic variables and it looks kind of interesting, but extra tabs in ubot are not good for me since i use already few tabs that customer use. Problem with this variables are that this variables are set by a customer. So first customer sets variables (title, link, description........) and then he clicks save button, then all this variables are saved in list and that is not problem. The problem is when i want to restore variables. When i m restoring i need to use SET command and then use next list item to give correct variable. And this works, but if i have 10000 variables i will have 10000 SET commands. So i ask if there is some kind of way to shorten this? And best thing will be to have a variable list and then just LOOP and use next list item for variable name and next list item for variable info. SO 1000 line code will eb shorten to like 10? But it looks like this is science fiction... Quote Link to post Share on other sites
Gogetta 263 Posted January 3, 2014 Report Share Posted January 3, 2014 you can use my Dynamic variables and set all with one node in under a second hope this helps http://www.screencast.com/users/pftg4/folders/Jing/media/d21b3912-f766-474a-8c50-ab154521818b Nice... Quote Link to post Share on other sites
pftg4 102 Posted January 3, 2014 Report Share Posted January 3, 2014 i m not sure if we understand each other. I have check dynamic variables and it looks kind of interesting, but extra tabs in ubot are not good for me since i use already few tabs that customer use. you don't need extra tab this is raw ubot code they are just defines you can add to your own code. The problem is when i want to restore variables. When i m restoring i need to use SET command and then use next list item to give correct variable. And this works, but if i have 10000 variables i will have 10000 SET commands. So i ask if there is some kind of way to shorten this? And best thing will be to have a variable list and then just LOOP and use next list item for variable name and next list item for variable info. SO 1000 line code will eb shorten to like 10? what you need is dynamic variables ubot does not support this Quote Link to post Share on other sites
the_way 52 Posted January 4, 2014 Report Share Posted January 4, 2014 what is actually going on in the memory with regards to the way those dynamic variables work, vs traditional variable setting in ubot? is there a different FIFO order or something? cheers. Quote Link to post Share on other sites
pftg4 102 Posted January 4, 2014 Report Share Posted January 4, 2014 no to simplify it dum it down so to speak adds everything to list then pulls from there it works like a mini database doesn't matter what order anything is in pftg4 1 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.