Jump to content
UBot Underground

Setting 500 Variables Trough List and Loop


Recommended Posts

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?

Link to post
Share on other sites

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

Link to post
Share on other sites

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.

  • Like 1
Link to post
Share on other sites

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

Show me that as ubot code pls

thx

  • Like 1
Link to post
Share on other sites

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...

Link to post
Share on other sites

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

Link to post
Share on other sites

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.

Link to post
Share on other sites

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

  • Like 1
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...