Jump to content
UBot Underground

How to cycle through Variables in a Loop


Recommended Posts

I have a semi complex bot here.  Basically I have a crapload of text areas each assigned a variable, and each value will be a number.

 

I need to do some math with the value inputted in each text box.  Since there will be anywhere from 10 to 100's of text areas when this is done, it would be way easier to accomplish this with a loop instead of an individual 'if' command for each one.  Each textarea has a certain value assigned to it already, and will be multiplied by whatever the user inputs in the text area.  Each textarea variable, and the number each texarea value will be multiplied by, are each in separate lists.

 

I don't need help with the math though, just a simple way to somehow cycle all the variables for each textarea in a loop.

 

Essentially as of now it would look like this,  One if statement for each texarea.  Obviously this will turn into 100's or 1000's of lines of code and I do plan on having a ton of text boxes as time goes on, where as if I could do it in a loop it would be just 10 or so.

if  #textarea1 >= 0
then 
set #newtotal = #textarea1 * #othervalue1 

if  #textarea2 >= 0
then
set #newtotal = #textarea2 * #othervalue2

if  #textarea3 >= 0
then
set #newtotal = #textarea3 * #othervalue3

etc

Fairly simple, however if it was possible to cycle through all the variables assigned to each text field via a list I could do this with a single loop instead of a million if commands.

 

For example, if I could add all the variables for each textarea to a list, I could accomplish all of that with one loop.  Something like:

Loop (cycle using list total %textareavariables)

set #current_text_area_item = (next list item %textareavariables)
set #current_text_area_item_value = (next list item %textareaitemvalues)

if #current_text_area_item >= 0
then set #newtotal = #current_text_area_item * #current_text_area_item_value\

Obviously I found out that it doesn't appear as though you can add actual variables to lists.  Like I'd want the variable list to be, #item1 #item2 #item3 etc, then the loop would check each variable in the list one at a time.

 

The end result would be #newtotal having the total number after calculating the value of each text box.

 

Please tell me there's a way to cycle through variables (not the variable values) in a loop so I don't need to write an if statement for every single text box!?

Link to post
Share on other sites

To put it more simply, say you had 10 text boxes in your ui panel.

 

How would you check the value of each text box in a loop?

 

Would be nice to load the variable for each text box into a list and use it in a loop.

Link to post
Share on other sites

You cannot have dynamically named variables in UBot Studio (basically THAT is what you would need to make your idea work).

 

So NO, it is not possible!

 

Sorry...

Link to post
Share on other sites
You can put each ui text box in a table column and call that cell >>>>loop each row. can u not?

I already tried that, doesn't work.  You cannot dynamically create or change a variable in any way at all with ubot and it totally stinks!

Link to post
Share on other sites

I mean I can generate all the if statements, and I could accomplish that with the lists, it's just I hate to use 1,000 lines of code when in all reality it could be done in 10.

Anybody think this is a feature worth considering for the near future?

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