ed08724 6 Posted July 22, 2016 Report Share Posted July 22, 2016 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? Quote Link to post Share on other sites
Brutal 164 Posted July 23, 2016 Report Share Posted July 23, 2016 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 Quote Link to post Share on other sites
ed08724 6 Posted July 23, 2016 Author Report Share Posted July 23, 2016 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. Quote Link to post Share on other sites
abbas786 78 Posted July 23, 2016 Report Share Posted July 23, 2016 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 "-" signHere is an example set(#A,"Hi Ed","Global") set(#B,"How are u ?","Global") set(#C,"{#A} - {#B}","Global") Hope it helps Quote Link to post Share on other sites
HelloInsomnia 1103 Posted July 25, 2016 Report Share Posted July 25, 2016 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. Quote Link to post Share on other sites
ed08724 6 Posted July 25, 2016 Author Report Share Posted July 25, 2016 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. Quote Link to post Share on other sites
HelloInsomnia 1103 Posted July 26, 2016 Report Share Posted July 26, 2016 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. 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.