Jump to content
UBot Underground

Create Table From File Problem


Recommended Posts

I'm seeing some unexpected behavior with the code snippet below:

            create table from file($add($special folder("Application Data"),"\\MyScript\\data.txt"),&taskList)
            wait(1)
            set(#currentRow,0,"Global")
            loop($table total rows(&taskList)) {
                set(#URL,$table cell(&taskList,#currentRow,0),"Global")
                set(#Domain,$table cell(&taskList,#currentRow,1),"Global")
                set(#Timer,$table cell(&taskList,#currentRow,2),"Global")
                set(#currentTime,$GetSecondsPastHour(),"Global")
                loop while($comparison(#currentTime,"< Less than",#Timer)) {
                    wait(1)
                    set(#currentTime,$GetSecondsPastHour(),"Global")
                }
                loop while($comparison(#usedThreads,">= Greater than or equal to",#threadCount)) {
                    wait(1)
                }
                increment(#usedThreads)
                MyFunction(#URL, #Domain)
                increment(#currentRow)
            }

Sometimes (not always), even though the data.txt file is properly formatted and populated with data, the script somehow seems to lose track of the #URL value set in the 5th line of code. When MyFunction is called the #URL value is blank, even though there is data at the 0,0 position of the data.txt file. Obviously ubot is reading the data into the &taskList table, otherwise the loop($table total rows(&taskList)) would be equal to 0, and MyFunction would never be called.

 

Furthermore, the debugger does show the expected value for #URL, however a UI Stat Monitor tied to #URL displays blank, while a UI Stat Monitor for the other variables displays the expected values. The only other function called between the set #URL and MyFunction is $GetSecondsPastHour(), which is a small python script that does not call the #URL variable at all.

 

Any ideas what might be going on here? It doesn't happen all the time, but when it does, it happens on the first iteration of the loop, i.e. row 0, which causes an error message later in the code. If I choose to continue rather than stop, the next row sees the same behavior, i.e. #URL remains blank.

 

I'm stumped. Help please.

Link to post
Share on other sites

It looks like your code should work so it's really hard to say with the information provided. If you could show us this happening somehow then maybe we can spot something which isn't right. Maybe provide a file that does this and the appropriate custom commands - which you can probably strip out the functionality out of MyFunction if its sensitive.

Link to post
Share on other sites

Apparently there is an undocumented restriction on variable assignments. Try running the code below with the debugger open (I'm using ubot 5.9.55)

ui stat monitor("URL: ",#url)
add list to list(%urls,$list from text("http://domain1.com,http://domain2.com,http://domain3.com,http://domain4.com,http://domain5.com",","),"Delete","Global")
with each(%urls,#url) {
    set(#url,"{#url}+/","Global")
}
add list to table as row(&myTable,0,0,$list from text("a,b,c,d,e",","))
add list to table as row(&myTable,1,0,$list from text("f,g,h,i,j",","))
add list to table as row(&myTable,2,0,$list from text("k,l,m,n,o",","))
set(#currentRow,0,"Global")
loop($table total rows(&myTable)) {
    set(#url,$table cell(&myTable,#currentRow,0),"Global")
    alert(#url)
    increment(#currentRow)
}

Logically, this should result in alert boxes appearing with the content "a", "f", and "k"

 

When run, the debugger does in fact show #url = "k"

 

However, the alert box displays "http://domain5.com"

 

It seems that after assigning a variable to a with each statement, that variable can no longer be reassigned any values outside of that statement, and the debugger is misrepresenting the value of that variable.

 

This is not mentioned anywhere on http://wiki.ubotstudio.com/wiki/With_Each

 

It was occurring only intermittently in my script because the with each statement only runs periodically.

 

Hope this helps someone.

Link to post
Share on other sites

It's because you're using a local variable which is taking precedent. Parameters in Ubot are local. Let me explain:

With each uses #url which is a local variable. Generally, this would be local to the define but since you are not in a define it's just local to your whole script as it is.

 

To show you what I'm talking about try this:

set(#var,1,"Local")
set(#var,2,"Global")
alert(#var)
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...