Jump to content
UBot Underground

Recommended Posts

trying to understand how to debug a problem such as "can't subtract strings".
I only get the error once every few hours.

when I click stop the script keeps loading pages in the browser window.
It continues to load different pages for a few minutes or sometimes seems to never stop.

I can't click stop because it thinks the script is already stopped so isn't clickable but the run button is.

 

I can't use the debugger to check variables if they continue to change from the running script.

Why doesn't the script stop when I click stop in the error box?

 

 

 

Link to post
Share on other sites

If you're running threads, it will keep running until the process is finished.

 

If you are in your code editor and you right-click - run from an internal point and it has a loop in it, then it isnt going to stop

Link to post
Share on other sites

A far as I know I am not running threads. I wrote all the code and not even sure what a thread is.

 

I just click the red run arrow at the top to start the program.

Link to post
Share on other sites

Please Share your code snippet so that anyone can help u in better way.

 

You can close the ubot studio from task manager and than start debugging ur script

 

There might be 2 possibilities

 

1) Either u are performing math calculations on 2 variables and not declaring or intializing them with value .

Here is an Example 
 

set(#A,10,"Global")
set(#B,5,"Global")
set(#C,$subtract(#A,#,"Global")

2) You are joining 2 variables with a "-" Operator and ubot has converted it into subtract function, Make sure to use space before and after the "-" sign

Here is an example
 

set(#A,"Hi Ed","Global")
set(#B,"How are u ?","Global")
set(#C,"{#A} - {#B}","Global")

Hope it helps

Link to post
Share on other sites

You should post your code if you are able to as it will make it easier to say what's going on but in relation to your error about subtracting strings. It likely means that one or more variables are not a number. You can use the $is number function to ensure they are numbers before trying to subtract them and if they are not then do something else.

Link to post
Share on other sites

I was not trying to get someone to debug my code.
I was just asking why the program doesn't stop when told to do so either via the error box or the stop button and how one would go about debugging when the variables have changed from the point of the error until the time I bring up the debugger.

Link to post
Share on other sites

I would create certain conditions that must be met for the program to move forwards. If those conditions are not met then instead of moving forward run a custom command such as this one:

define Debug(#what) {
    create folder($special folder("Application"),"Debug")
    save to file("{$special folder("Application")}\\Debug\\what.txt",#what)
    save browser image("{$special folder("Application")}\\Debug\\browser.png")
    alert("Debug info recorded!")
    pause script
}

This will save the "what" which is what you were doing (you fill this out) and a browser screenshot. It will also pause the script so you can see whats going on but continue if you wish or stop it.

 

Here is an example usage of it:

loop(2) {
    navigate("http://imautobots.com/","Wait")
    if($exists(<innertext="Ubot Launcher">)) {
        then {
            click(<innertext="Ubot Launcher">,"Left Click","No")
            wait for browser event("DOM Ready","")
            wait for browser event("Everything Loaded","")
        }
        else {
            Debug("Ubot Launcher link not found")
        }
    }
    if($comparison($url,"=","http://imautobots.com/")) {
        then {
            alert("ok!")
            stop script
        }
        else {
            Debug("Not on homepage")
        }
    }
}
define Debug(#what) {
    create folder($special folder("Application"),"Debug")
    save to file("{$special folder("Application")}\\Debug\\what.txt",#what)
    save browser image("{$special folder("Application")}\\Debug\\browser.png")
    alert("Debug info recorded!")
    pause script
}

It's meant to not meet the second condition and it's on a loop for 2 so that you can see it pauses the script and you can continue it if needed or stop it.

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