Jump to content
UBot Underground

Does Ubot Have A "goto" And "label" To Control The Flow Of "if" Statements?


Recommended Posts

So I've been using "Automate 6" since 2006 before discovering Ubot like 3 weeks ago.  Automate 6 has the ability to let you set up "if" statements as well.  

 

One thing most of my Automate 6 bots benefited from was they had actions like "Goto" and "Label".  Here's what they look like:

 

http://i64.tinypic.com/2vab8qr.jpg

 

I cannot find an equivalent in Ubot.  The way it would work is you would stick a "Goto" anywhere in your code and if you had previously put the "Label" (you give it any name you want) in the code, the task would immediately go to that "Label" and continue from there.  

 

Here's my current ubot code:

 

http://i66.tinypic.com/11hcg2u.jpg

 

And here's sort of the equivalent in Automate 6.  I just named the Label "PopRocks" as an example:

 

http://i64.tinypic.com/2pt0xab.jpg

 

Is there an equivalent feature of Ubot that allows you to define a certain point in the task and stick a "goto" and the task goes immediately to where you told it to "goto"?

 

I hope that makes sense.  I can try to clarify further if needed.

Edited by scriptbit
Link to post
Share on other sites

I too love those functions in macrotoolwork..

 

In ubot, "define" is the similar thing to those..

if you use "define" as a function , i think a program needs a lot of function like that .

in fact , we only need to jump to label . Done

Link to post
Share on other sites

Useful if ubot add something like that.

 

This is how i do something similar

doStuff("dothis")
define doStuff(#doStuffQuery) {
    if($comparison(#doStuffQuery,"=","dothis")) {
        then {
            alert(#doStuffQuery)
        }
        else if($comparison(#doStuffQuery,"=","dothat")) {
            alert(#doStuffQuery)
        }
        else {
        }
    }
}

Link to post
Share on other sites

goto is frowned upon because it promotes poor coding practice. 

 

Got your back up against the wall, something not working right, lets jump here with a goto

 

instead program in for scenarios that cause issues and how to deal with them propelry and a goto would not be needed.

 

Easy way out is not always the best way out.

 

 

This may or may not be the case for you and im not trying to bash anyone here.  just trying to point out what a mess it can cause in the code.

  • Like 2
Link to post
Share on other sites

I too love those functions in macrotoolwork..

 

In ubot, "define" is the similar thing to those..

 

 

PLEASE give me an example of how you use it like how I am describing Label and Goto.  Thank you in advance!

 

Useful if ubot add something like that.

 

This is how i do something similar

doStuff("dothis")
define doStuff(#doStuffQuery) {
    if($comparison(#doStuffQuery,"=","dothis")) {
        then {
            alert(#doStuffQuery)
        }
        else if($comparison(#doStuffQuery,"=","dothat")) {
            alert(#doStuffQuery)
        }
        else {
        }
    }
}

 

Ok I want to try this.. Where do I put this kind of raw code?  

Link to post
Share on other sites

goto is frowned upon because it promotes poor coding practice. 

 

Got your back up against the wall, something not working right, lets jump here with a goto

 

instead program in for scenarios that cause issues and how to deal with them propelry and a goto would not be needed.

 

Easy way out is not always the best way out.

 

 

This may or may not be the case for you and im not trying to bash anyone here.  just trying to point out what a mess it can cause in the code.

 

I was not even aware of "macrotoolwork" but that now makes 2 competing softwares to ubot that have this feature.  

 

I see your point that it may not be good coding practice but consider how much faster all our bots would be constructed if only Ubot contained these two features.  Everybody who was the Automate and Macrotoolwork customer base would comfortably be able to jump right into Ubot.  

 

Automate 6 is built on "Basic" coding language, which honestly I don't know.  I stuck with the gui (yeah I'm a noob like that).  I don't know how "Basic" programming language works in the raw code of it but seems it will allow for goto and label.  What is Ubot built on?  

 

However, I will try the solutions presented above.  I do see Ubot does have many features that the others don't so I am very excited to try to master it.  Just getting through this initial learning curve is where I'm at now.

Link to post
Share on other sites

yup like Kreatus s

 

or

 

you have you whole sequence in a define "login"

 

---------------- define login()

next list item = abc@abc.com,sdjfl;kjejflkj

fill form with login details

hti submit

wait for element to exist

if element not exist

    login()   which means start over again until the list runs out or you have a valid login

--------------

continue the rest of you bot code

post a tweet to twitter
 

 

You can use the same login with proxies.

 

Regards,

Nick

 

  • Like 1
Link to post
Share on other sites

Interesting, long time ago I found a post from a member who said using Return command with no parameter makes the code go to the beginning of the last loop command (the closest to Return).

Might not be "Goto" but, I tested it that time and if remember, it worked for me.

 

Just copy the code you want it to goto in a define

 

you have you whole sequence in a define "login"

 

---------------- define login()

next list item = abc@abc.com,sdjfl;kjejflkj

fill form with login details

hti submit

wait for element to exist

if element not exist

    login()   which means start over again until the list runs out or you have a valid login

--------------

continue the rest of you bot code

post a tweet to twitter
 

 

You can use the same login with proxies.

 

Regards,

Nick

Link to post
Share on other sites

I use to do that but now I cant remember how exactly.

 

I am trying to make some code but keep getting exceeding list error.

 

but I know that logic worked with proxies

 

and what kreatus has works too

 

but I believe I was using "$random list item" with proxies.

oh, wait ya

use list "position o" and "remove from list @ position 0"

 

lemme work it out, I am tired too

sorry

 

CD

Link to post
Share on other sites

Here is another way to look at it too...

clear list(%data)
add list to list(%data,$list from text("one@abc.com,ljkfsldkjfs;lkdjf
two@abc.com,sld4df5s7f67f7
three@abc.com,lsdjfsl;kdjfg465463",$new line),"Delete","Global")
loop while($comparison(%data,"!= Does not equal",$nothing)) {
    set(#NLI,$list item(%data,0),"Global")
    comment("this simulates the \"$exitsts\" function")
    set(#elemnt exists,$spin("\{true|false\}"),"Global")
    if(#elemnt exists) {
        then {
            alert("continue")
            comment("run you define or code here")
            remove from list(%data,0)
        }
        else {
            alert("add item to bad list")
            remove from list(%data,0)
            comment("and continue back to top")
        }
    }
}

you can do many cool things with loop while

 

Regards,
Nick

Link to post
Share on other sites

here is how one might do proxies

clear list(%data)
add list to list(%data,$list from text("one@abc.com,ljkfsldkjfs;lkdjf
two@abc.com,sld4df5s7f67f7
three@abc.com,lsdjfsl;kdjfg465463",$new line),"Delete","Global")
clear list(%proxies)
add list to list(%proxies,$list from text("123.456.789:8080
456.321.789:1000
555.55.566:888",$new line),"Delete","Global")
loop while($comparison(%data,"!= Does not equal",$nothing)) {
    set(#UI porxy,$test proxy(),"Global")
    comment("if proxy is  good set proxy")
    if(#UI porxy) {
        then {
            change proxy(#UI porxy)
        }
    }
    comment("navigate to site logic")
    set(#NLI,$list item(%data,0),"Global")
    comment("this simulates the \"$exitsts\" function")
    set(#elemnt exists,$spin("\{true|false\}"),"Global")
    if(#elemnt exists) {
        then {
            alert("continue")
            comment("run you define or code here")
            remove from list(%data,0)
        }
        else {
            alert("add item to bad list")
            remove from list(%data,0)
            comment("and continue back to top")
        }
    }
}
define $test proxy {
    loop while($comparison(%proxies,"!= Does not equal",$nothing)) {
        set(#rand proxy,$next list item(%proxies),"Global")
        comment("reset list pos for continuous loop, at least till the list runs out")
        if($comparison($list position(%proxies),"= Equals",0)) {
            then {
                set list position(%proxies,0)
            }
        }
        if($comparison(%proxies,"= Equals",$nothing)) {
            then {
                alert("feed my I am out of proxies.")
                comment("and/or use stop script")
            }
        }
        comment("test proxy code here

and if proxy is good set value to true")
        if($spin("\{false|true\}")) {
            then {
                return(#rand proxy)
            }
            else {
                remove from list(%proxies,0)
                return("false")
            }
        }
    }
}

the define command is very powerful

 

you can read more about the define command << there

 

#define

 

Regards,
Nick

  • Like 1
Link to post
Share on other sites

I know this doesn't directly answer your question and this is quite long, you will need the Local Dictionary plugin as well to see this properly in Ubot but I hope it shows how you can use Defines instead of something like a GoTo Label:

clear list(%log)
clear list(%accounts)
add list to list(%accounts,$list from text("first|1
second|2
third|3
fourth|4
fifth|5",$new line),"Delete","Global")
loop($list total(%accounts)) {
    clear list(%account)
    add list to list(%account,$list from text($next list item(%accounts),"|"),"Delete","Global")
    LoginController($list item(%account,0), $list item(%account,1), $rand(1,3))
}
define LoginController(#_email, #_password, #_retryCount) {
    DeclareLoginProperties(#_email, #_password, #_retryCount)
    loop while($plugin function("LocalDictionary.dll", "$local dictionary get", "loginProcessRunning")) {
        Login()
        UpdateLoginStatus()
    }
}
define DeclareLoginProperties(#_email, #_password, #_retryCount) {
    plugin command("LocalDictionary.dll", "local dictionary add", "email", #_email)
    plugin command("LocalDictionary.dll", "local dictionary add", "password", #_password)
    plugin command("LocalDictionary.dll", "local dictionary add", "retryCount", 0)
    plugin command("LocalDictionary.dll", "local dictionary add", "maxRetryCount", #_retryCount)
    plugin command("LocalDictionary.dll", "local dictionary add", "success", "false")
    plugin command("LocalDictionary.dll", "local dictionary add", "loginProcessRunning", "true")
}
define Login {
    comment("Pretend Login Process")
    comment("These set commands replace (a) type text; its an example
of how we use the local dictonary.")
    set(#_email,$plugin function("LocalDictionary.dll", "$local dictionary get", "email"),"Local")
    set(#_password,$plugin function("LocalDictionary.dll", "$local dictionary get", "password"),"Local")
    set(#_loginSuccessful,$spin("\{true|false|false|false\}"),"Local")
    plugin command("LocalDictionary.dll", "local dictionary add", "success", #_loginSuccessful)
}
define Log(#_message) {
    comment("In this case we just use a list to keep a basic log")
    add item to list(%log,#_message,"Don\'t Delete","Global")
}
define UpdateLoginStatus {
    comment("If the login is successful, log it and return.")
    if($comparison($plugin function("LocalDictionary.dll", "$local dictionary get", "success"),"=","true")) {
        then {
            plugin command("LocalDictionary.dll", "local dictionary add", "loginProcessRunning", "false")
            Log("Login Process: Successfully logged in account: {$plugin function("LocalDictionary.dll", "$local dictionary get", "email")}")
        }
        comment("If it failed, check the retry count, and log.")
        else {
            plugin command("LocalDictionary.dll", "local dictionary increment", "retryCount")
            if($comparison($plugin function("LocalDictionary.dll", "$local dictionary get", "retryCount"),">",$plugin function("LocalDictionary.dll", "$local dictionary get", "maxRetryCount"))) {
                then {
                    plugin command("LocalDictionary.dll", "local dictionary add", "loginProcessRunning", "false")
                    Log("Login Process: Account: {$plugin function("LocalDictionary.dll", "$local dictionary get", "email")} ... Max retries hit, account Failed to login")
                }
                else {
                    set(#_retryAttemptsLeft,$add($subtract($plugin function("LocalDictionary.dll", "$local dictionary get", "maxRetryCount"),$plugin function("LocalDictionary.dll", "$local dictionary get", "retryCount")),1),"Local")
                    Log("Login Process: Account: {$plugin function("LocalDictionary.dll", "$local dictionary get", "email")} login failed, retrying... {#_retryAttemptsLeft} attempts left")
                }
            }
        }
    }
}
  • Like 1
Link to post
Share on other sites

As has been described, define is the most obvious replacement for this. Use it the same way that you "label" commands inside Automate 6:

 

Essentially, any time you create a defined command, you are building an area of code you can "go to" simply by calling that command's name. The way most here use defined commands is to have one tab with various defined commands (ie labeled sets of code), and then your script in a separate tab that is a series of conditionals that refer back to different defined commands. 

Link to post
Share on other sites

For anyone getting used to UBot Studio there are definitely some programming

concepts that you won't see here.  Thankfully, (and my fingers are crossed too)

that "GoTo" statements will never appear. 

 

The person who created that ability in the distant past should have been taken

out back and shot.

 

Now you know where I stand on that issue.  LOL

 

As far as Define commands, I hardly ever use them except in specialized

functions.  The one piece of advice that I give a lot of users when I see them

using Defines is to develop that code outside of the Define.  Make sure that it

works 100% of the time and the exact way you want it to run.  Debugging code

inside of a Define is impossible simply because you can not watch its execution

at least visually.

 

I have about 45 bots scraping 45 different websites and they all are using 95%

of the same code.  My master source code I will add to a new bot and then

tweak out a special section and then I am done.

 

Logic is the key.  Using variables is another key. 

 

Plan, Plan and Plan.  It will make a difference.  As TJ mentioned, don't use

shortcuts in your coding.  There will price to pay if you do at some point either

with a lost client or an impossible coding delima to get over.

 

Buddy

Link to post
Share on other sites
  • 2 weeks later...

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