Boot Camp – Advanced Define’s – UBot Studio Source Code

Only Registered Users are able to view pricing.

In this tutorial I will attempt to show you how to use a “define” command/function, I call them “methods”. A method can be a group of nodes or just one node that accomplishes a specific task. Much like if you have separate tabs to do different things in your program. Tabs are containers, defines are custom containers that can contain groups of other commands and functions even your custom commands/functions.


Description

UBot Boot Camp

Advanced Define’s

Source Code

 

Hello UBotter!!UBotters!!

 

In this tutorial I will attempt to show you how to use a “define” command/function, I call them “methods”. A method can be a group of nodes or just one node that accomplishes a specific task. Much like if you have separate tabs to do different things in your program. Tabs are containers, defines are custom containers that can contain groups of other commands and functions even your custom commands/functions.

 

Why do I need to do all this extra work man?

  • Saves memory – Local variables and list are not saved to memory when used inside define’s. :)
  • Reusable code – You can reuse these methods again and again in your program.
  • Readability – You can name your methods to be more descriptive and not waist time thinking about it for a few minutes. You know what it is at a glance.
  • Errors – When you throw an error you will see exactly which define it came from by its name.
  • Developing – When the scope is Local it does not show in the debugger. This means less memory to refresh and fewer restarts of the studio.
  • Accessibility – You can find your code much easier.
  • Your own libraries – Soon you will have a library to use over and over, it just gets easier as you go. You can share these with others in the bot bank or in your private bot bank. From the bank you can just drag them on over with out the actual define and it will compile just dandy.
  • Leaner & Meaner programs are better! UBot is 32bit and it only gets 3-4 GB of Ram per process so, we need to trim the fat.

 

ubot-boot-camp-defines-commands-tab-4

Custom Commands

Much like the commands given to you in UBot, a group of them may be called a “sub routine”, those nodes can be put in a define. You can put a set of commands/nodes into the define container and run those synchronously to get the desired result and use it more than once throughout your code.

 

 

 

ubot-boot-camp-defines-forum-search-code-snppet

Just supply some parameters, a user name and a password. You can see that it has a dynamic nature where those two field always change.

 

ubot-boot-camp-defines-functions-tab-3Custom Functions – are a little more snazzy and very helpful. The purpose of a function is to return something. Anything under “Parameters” the tool box are functions. Thin about what they do, like $next list item, this returns/gives you the next list item. It auto increments the list position and keeps track of where it is for you. The function $list from file, it reads in all the lines of a file and the parameter is a file path. Or $scrape page, it return to you the text of a page with in the parameters given. The $document text function is a good one, it “returns” whatever is in the UBot browser window so you may manipulate or do as you wish with it.

 

ubot-boot-camp-defines-forum-search-code-snppet-2

 

Someone gave you some regex to get the filename?  .*?\\|\..*

Do you want to remember that regex?

Do you want to remember how to use it?

Of course not, just make the function and save it somewhere for future use. Also, you can reuse that function for another filename somewhere else in your code.

 

Typically, I put Custom Commands and Custom Functions in their own tabs and when I compile, I hide them so users don’t see them. In larger programs. These tabs can get very big and I split them off to reduce the render times of each tab.

 

Another cool thing about these Methods are you can pass variables and functions via parameters. Parameters are bits of data you may need to share between define’s or from other places, like from files or lists etc.

 

In addition there is this notion called a “Scope”. You may have noticed inside lists and sets there is a drop down to set the “Scope” to the default “Global” or “Local”. Local means the data contained in a variable or list is localized to the define that “list” or “set” node it resides in. It also means it wont be seen in the debugger. So when it works that is the time to change necessary nodes to “Local”. This is a must do while multi – threading.

 

When you create your own methods they will show up in the search box or in the toolbox either under Commands>>Custom Commands or Parameters>>Custom Functions like so.

 

For some more info on defines you can see the wiki custom commands post here
In the attached .ubot file are some examples and a basic search bot,they are fully commented.

 

The First Tab – “UBot Forum Search”

This is a simple bot to demo all the methods together. It searches the UBot forum by keyword and returns N quantity of results.

ubot-boot-camp-define-ubot-search-tab-1

In the next tab “Examples” are the how to do’s.

ubot-boot-camp-defines-examples-tab-2

Building Functions and Commands

 

When I build a command I do so in the tab I am making it for initially. Then I go to code view (Ctrl + i), cut it and paste into commands tab where I need it to go. Then I switch back to node view (Ctrl+i) and save with (Alt + f + s). This saves from all that tab switching. i also will build them right in the commands tab. Like a login sequence.

 

In order to run a define you must drag your command into the node view box from the toolbox or search box. Then I right click and run. If it is the only command then you can press the F5 key.

Testing and Building Functions

I usually test a function in an “Alert” command and build it in the “Functions” tab. Then place my functions where needed.

 

When should I define a method?

If you are copying and pasting a node or group of nodes more than once it is time to make that baby/those babies into a method.

Sometimes you just have to use a variable and others they should be a made into a function. Setting variables chops away at precious memory.

 

Methods have many hidden secrets that you can only find with practice.


Reviews (1)

1 review for Boot Camp – Advanced Define’s – UBot Studio Source Code


  1. 5 out of 5

    (verified owner):

    Perfect like other Code Docta tutorials. Very helpful. This will speed up a lot UBot Studio learning.
    Thank you Code Docta!

Add a review


Seller Info

Please for the sake of others come back and share your experience with THEM.

If anyone needs consulting for any of my free products I charge $50 for the first hour and $35 for additional hours. 1 Hour minimum and if you don’t use the full hour you still get the minutes left over for another time.

 

Most documentation is located here…

UBot Expert

Tutorials


Send a Private Message to Vendor